Using Raw SQL Queries

Entity Developer allows mapping results of raw SQL queries to classes for Entity Framework Core.

ExpandedToggleIcon        How to Create a Class from a Raw SQL Query

To create a class from the result of raw SQL query, perform the following steps:

1.Add a new class to the model as usually (See Creating and Editing Classes). Don't set its Table property. You also don't need to specify its properties, because they can be autogenerated from the results of the query.
2.In the properties of this class, click the Raw SQL Query property. Then click the three-dotted button in this property.
 
raw-sql-query-property
3.In the opened editor, enter the SQL query. You may click Execute and preview the data to make sure everything is correct.
4.Click OK. Entity Developer will ask whether to re-generate the class's Properties collection. Click Yes to re-generate properties. Property names will be generated from the names of the resultset columns.
 
raw-sql-query-editor

Note that you can edit the Raw SQL Query property only for classes with the empty Table property.

 

ExpandedToggleIcon        Specificities of Raw SQL Query Classes

For classes of entity type, generated from a raw SQL query, Entity Developer generates an IQueryable collection, not an EntitySet.
For classes of query type, generated from a raw SQL query, Entity Developer generates an DbQuery collection
The objects, returned by a raw SQL query, are read-only.

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.