简体   繁体   中英

LINQ CROSS JOIN Error

I got this error

Object of type ' System.Data.Objects.ObjectQuery`1[XXX.Model.Cust_ProfileTbl] ' cannot be converted to type ' System.Data.Entity.DbSet`1XXX.Core.Model.Cust_ProfileTbl] '.

When I tried CROSS JOIN ing these 2 tables with LINQ. Could anyone advise what should I do?

var Cust_ProfileTbl = service.DBContext.Set<Cust_ProfileTbl>();
var Cust_GroupTbl = service.DBContext.Set<Cust_GroupTbl>();

var test =
from cg in Cust_GroupTbl
from c in Cust_ProfileTbl
select new { intCustGroup = cg.intCustGroup, bintAccountNo = c.bintAccountNo };

Cust_ProfileTbl.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace XXXX.Core.Model
{
    [Table("Cust_ProfileTbl")]
    public partial class Cust_ProfileTbl  
    {
        [Key]
        public long bintAccountNo { get; set; }
    }
}

Cust_GroupTbl.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace xxxx.Core.Model
{
    [Table("Cust_GroupTbl")]
    public partial class Cust_GroupTbl
    {
        [Key]
        public int intCustGroup { get; set; } 
    }
}
var test =
from cg in service.DBContext.Cust_GroupTbls
from c in service.DBContext.Cust_ProfileTbls
select new { intCustGroup = cg.intCustGroup, bintAccountNo = c.bintAccountNo };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM