【问题标题】:Want to select a single column from a table in database and store it in a list asp.net想要从数据库中的表中选择单个列并将其存储在 asp.net 列表中
【发布时间】:2019-10-28 03:06:41
【问题描述】:

我在 asp.net 中工作并使用实体框架 我想执行这样的查询,

SELECT Name FROM Employees 

我想在 asp.net 中使用 linq 执行此查询?

【问题讨论】:

  • 几乎所有教程都会从如何选择数据作为第一个示例开始。从那里开始,谷歌教程或视频,然后开始阅读/观看。 Stack Overflow 不是寻求指导或教程或学习如何...的地方,这被认为是 off-topic

标签: c# asp.net database linq


【解决方案1】:
var result = (from c in context.Employees select c.Name).ToList();

List<string> result = (from c in context.Employees select c.Name).ToList();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 1970-01-01
    • 2019-03-17
    相关资源
    最近更新 更多