以下是简单SQL查询...我希望使用selected field not all table fields
获取Entity frame work List function
。
"Select CustName, CustEmail, CustAddress, CustContactNo from Customers"
答案 0 :(得分:2)
我假设您已经定义了上下文并映射了表。
var results = dbContext.Customers.Select(x => new { x.CustName, x.CustEmail, x.CustAddress, x.CustContactNo }).ToList();