我有以下的LINQ code ...
I have the following linq code...
CMSDataContext dc = new CMSDataContext();
var q = from u in dc.CMSUsers
join d in dc.tblDistricts
on u.DistrictCode equals d.District into orders
select u;
区显示了此错误: tblDistrict.District'和'tblDistrict.District
District shows this error: Ambiguity between 'tblDistrict.District' and 'tblDistrict.District'
任何想法?
编辑:
事实证明,我在两个不同的dbml文件具有相同的表。很显然,我不能这样做。我将不得不最终从一个DBML文件从不同的DBML文件加入一个表与另一个表。如果任何人都可以见识一下如何做到这一点,我会认为这是一个答案。谢谢你。
It turns out that I had the same table in two different dbml files. Apparently, I cannot do this. I will have to end up joining a table from one dbml file with another table from a different dbml file. If anyone can enlighten me on how to do this, I will deem it as an answer. Thanks.
如果您有两个表之间的FK releationship,LINQ到SQL会自动创建一个属性吧。
If you have a FK releationship between two tables, LINQ-to-SQl will automatically create a property for it.
例如,如果您订购的对象有一个客户ID这是一个Foriegn关键客户表,订单将自动获得一个顾客财产。如果你已经有一个顾客财产,就会有冲突。
For example, if you Order object has a CustomerID which is a Foriegn key to the Customers table, Order will automatically have a Customer property. If you already have a Customer property, there will be a conflict.