如何将 Sql 查询的结果映射到 Net Core 2 中的对象中?
How to Map the results of Sql query onto Objects in Net Core2?
如何将 SQL 命令的结果映射到 Net Core 中的 class 对象,使用
SqlCommand() 还是 FromSql()?有人可以为 Net Core 更新这个答案,还是语法仍然相同?
How can I map the results of a sql query onto objects?
使用 EntityFramework 核心,您只需使用 yourDbContextInstance.Set<T>().FromSql("your sql statement");
其中 T
是您的 class。
但是,您的 sql 必须 return 您的 class.
上的所有属性
有关详细信息,请参阅 documentation。
如何将 SQL 命令的结果映射到 Net Core 中的 class 对象,使用 SqlCommand() 还是 FromSql()?有人可以为 Net Core 更新这个答案,还是语法仍然相同?
How can I map the results of a sql query onto objects?
使用 EntityFramework 核心,您只需使用 yourDbContextInstance.Set<T>().FromSql("your sql statement");
其中 T
是您的 class。
但是,您的 sql 必须 return 您的 class.
有关详细信息,请参阅 documentation。