这是我的LINQ查询,请帮我改变此LINQ查询以使用Lambda表达式进行查询:
var query = from d in db.customers
from s in db.tbl_states
where d.cust_state == s.state_id
select new
{
d.cust_name,
s.state_name
};
答案 0 :(得分:2)
试试这个:
var query =
db.customers.Join (
db.tbl_states,
d => d.cust_state,
s => s.state_id,
(d, s) => new { d.cust_name, s.state_name }
);
答案 1 :(得分:2)
这应该这样做:
var query = db.customers.Join(db.tbl_states, d => d.cust_state, s => s.state_id, (d, s) => new { d.cust_name, s.state_name });
答案 2 :(得分:2)
我猜你的linq
应该是这样的
var query = from d in db.customers
join s in db.tbl_states on d.cust_state equals s.state_id
select new
{
d.cust_name,
s.state_name
};
代表Lambda
var list = db.customers
.Join(db.tbl_states,
s => s.tbl_states,
d => d.state_id,
(s, d) => new
{
d.cust_name,
s.state_name
});