这是我的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
};
试试这个:
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 }
);
应该这样做:
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 });
我猜你的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
};
for 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
});