Linq的问题加入了多个密钥?

时间:2011-03-07 19:11:17

标签: linq join

我在linq加入时遇到了一些错误

我的查询是这样的:

 from inv in SellServiceInvoice.All()
    join Ent in Entity.All() on new { CID = inv.EntityID, CType = inv.EntityTypeID }
    equals new { CID =(long) Ent.EntityID, CType =(long) Ent.EntityTypeID}  
    select new {...}

问题1:为什么我必须添加''(long)''虽然类型已经很长了!

问题2:它给了我以下例外:

不支持construtor'Void .ctor(Int64,Int64)'

1 个答案:

答案 0 :(得分:1)

你试过了吗?

from inv in SellServiceInvoice.All()
from Ent in Entity.All() 
where inv.EntityID = CID =(long) Ent.EntityID && 
      inv.EntityTypeID == (long)Ent.EntityTypeID
select new {...}