简体   繁体   English

SQL语句中的实体框架对象

[英]Entity Framework objects from SQL Statement

I've been working on a project which is based on PowerBuilder and DataWindow objects. 我一直在研究基于PowerBuilder和DataWindow对象的项目。 Now, one of the things we want is to "grab" the DataWindow objects and convert them to .NET objects (in C#) by basing them on the query. 现在,我们想要做的一件事情是“抓取” DataWindow对象,并根据查询将它们转换为.NET对象(在C#中)。 From that query I want EF to analyse it and build an object that mirrors the object retrieved by that query/datawindow. 从该查询中,我希望EF对其进行分析并构建一个对象,该对象反映该查询/数据窗口检索到的对象。 The data is pulled from 4 different tables on a Sybase ASE database. 数据是从Sybase ASE数据库的4个不同表中提取的。

I was under the impression that I could tell EF to behave like that by passing it the query and letting it build the object but I've been unable do to so and I've sort of hit a brick wall since DataWindow.NET (from Sybase) is a discontinued project (in 2008) and I really can't find any other alternative besides EF. 我的印象是我可以通过向EF传递查询并让它构建对象来告诉EF那样的行为,但是我一直无法做到这一点,而且自从DataWindow.NET( Sybase)是一个已停产的项目(在2008年),除EF外,我真的找不到其他选择。

If the intended behavior is possible, could someone point me in the right direction? 如果可能的行为是可能的,那么有人可以向我指出正确的方向吗? And if not, is there any component/framework that behaves like intended? 如果不是,是否有任何组件/框架的行为像预期的那样?

Entity Framework doesn't work this way. 实体框架无法以这种方式工作。 You can't give it some SQL and have it hydrate some .NET objects for you. 您不能给它一些SQL并为它添加一些.NET对象。 You can however do this using Dapper-dot-net . 但是,您可以使用Dapper-dot-net进行此操作。

https://github.com/StackExchange/dapper-dot-net https://github.com/StackExchange/dapper-dot-net

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM