【问题标题】:How to retrieve only user defined properties of a SQL Server database model如何仅检索 SQL Server 数据库模型的用户定义属性
【发布时间】:2020-12-01 04:19:44
【问题描述】:

我有类似的数据库模型

class A
{ 
    public string a;
    public string b;
    public string c;
    . 
    .
    .
}

我只想从数据库模型 A 中检索属性 a 和 b,而不是检索整个模型 A。在 Entity Framework Core 中有什么方法可以使用存储过程来做到这一点?

【问题讨论】:

    标签: sql-server asp.net-core stored-procedures .net-core entity-framework-core


    【解决方案1】:
     var result = dbcontext.Entity
       .Select(x => new { x.ServerName, x.ProcessID, x.Username })
       .ToList();
    

    我想这会解决你的问题!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多