【发布时间】:2020-07-13 13:22:22
【问题描述】:
我只想检索数据库的一列。以下代码确实有效:
这是我在 mysql-table/model-in-EF6 中的客户
public partial class customers
{
public customers()
public int CustomerID { get; set; }
public string FullName { get; set; }
public string Mobile { get; set; }
public string Email { get; set; }
public string Address { get; set; }
public string Image { get; set; }
}
public List<customers> GetAllCustomers()
{
return myContext.customers.ToList();
}
这是我的问题:
var GetOneColumn = myContext.CustomerRepository.GetAllCustomers().Select(f=>f.FullName);
它是否从数据库中的客户检索所有列,然后从检索到的数据中仅选择一列(全名),它仅从数据库中检索一列(全名)?如果它从数据库中检索所有数据,那么正确的代码是什么(Linq)?
我怎么能找到那个?
【问题讨论】:
标签: c# entity-framework-6