select * from tabel1 inner join table2 on tabel1.id = table2.recipegroupid or tabel1.id = table2.recipeitemid
换成where一样的 var result = from t1 in table1 from t2 in table2 where t1.id == t2.recipegroupid || t1.id == t2.recipeitemid select t1; 或者子查询
那就分别Join,将结果集Union 如果是内存对象就好办了(自己实现一个比较器),SQL查询没想到更好的办法 如果两个字段只有一个有值,那就用IsNull(table2.recipegroupid, table2.recipeitemid) Linq中用Nullable<int>.HasValue判断 这种表的设计没有遇到过,一个表的主键同时对应到另一个表的两个字段,如果用到了联合主键,表之间也应该保持对应
昨天回答过你了。 [quote=引用 1 楼 dongxinxi 的回复:] 换成where一样的 var result = from t1 in table1 from t2 in table2 where t1.id == t2.recipegroupid || t1.id == t2.recipeitemid select t1; 或者子查询
8,493
社区成员
4,736
社区内容
加载中
试试用AI创作助手写篇文章吧