ID CountryName
1 New Zealand
2 United States
3 Australia
4 United Kingdom
5 Europe
6 Japan另一个表是:
ID CountryId TypeId
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 2 3
7 3 1
8 3 2
9 3 3
10 4 1
11 4 2
12 4 3
13 5 1
14 5 2
15 5 3
16 6 1
17 6 2
18 6 3第一个表叫Country,第2个表叫MarketRate,现在我要通过根据MarketRate表中存在的所有的CountryId,来获取对应的Country表信息。如何写Linq to Entity?如果直接写SQL语句就很好写 select * from Country inner join MarketRate on Country.ID=MarketRate.CountryId但是Linq to Entity我不会写
比如EntitySet代表Country,如何写?
EntitySet.Where(c=>c.ID.....??
1 New Zealand
2 United States
3 Australia
4 United Kingdom
5 Europe
6 Japan另一个表是:
ID CountryId TypeId
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 2 3
7 3 1
8 3 2
9 3 3
10 4 1
11 4 2
12 4 3
13 5 1
14 5 2
15 5 3
16 6 1
17 6 2
18 6 3第一个表叫Country,第2个表叫MarketRate,现在我要通过根据MarketRate表中存在的所有的CountryId,来获取对应的Country表信息。如何写Linq to Entity?如果直接写SQL语句就很好写 select * from Country inner join MarketRate on Country.ID=MarketRate.CountryId但是Linq to Entity我不会写
比如EntitySet代表Country,如何写?
EntitySet.Where(c=>c.ID.....??
解决方案 »
- TreeView控件 在IE7 IE8 上浏览时子节点不可展开
- js 不带警告的确定框 怎么实现???
- Javascript如何获取后台lable的Text值?
- 关于Nhibernate 的many-to -one问题
- webpart匿名访问其他用户的布局
- Asp.net AJAX-Enabled Web Site项目里cs找不到aspx里的控件?
- 求救!!我在替换字符的时候产生乱码
- 正则表达式。。。。求助
- 请问一个DATABIND技术到底是什么意思?书上面说的太少了,有点不明白!谢谢~
- 请问在VS中如何引用命名空间?
- .net中,js里面的值怎么通过HiddenField传入后台cs呢?
- 请教怎么写一个快递单打印程序啊,比如圆通速递单的打印
join m in db.MarketRate on c.ID equals m.CountryId into t1
from p in t1.DefaultIfEmpty()
select new
{
ID=c.ID,
.........
};
join m in db.MarketRate on c.ID equals m.CountryId
select new
{
ID=c.ID,
.........
};
我是不是可以这样写:
AllEntities代表IQueryable<Country>
AllEntities().Where(e =>
e.MarketRates.Any(
et => et.CountryId==e.ID)
这样出来,会产生重复行吗?