Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my one of the project I am not having control over database because it is managed by client. We are supposed to create UI to show values from DB. In some stored procedures user is returning data through Dynamic SQL Query. Now we are finding issue in creating edmx objects in Entity Framework for these procs. Guys please help here.

Technology : ASP.Net MVC, Entity Framework 5, MS-SQL Server

What I have tried:

We tried using ADO.Net but we want to call the same through enterprise library. It would be definitely handled by Microsoft.
Posted
Updated 27-Mar-19 6:31am

Seems like you would want to build an IQueryable<T>. Search on Dynamic Query Expression on EF to get more information. Here's one example that may help you get started: Dynamic Query Expressions With Entity Framework | Code with the wind[^]

If you are expecting a different set of results then you can use IEnumerable<dynamic> to return anonymous object based from row sql dynamic query.

Also, if you want to take advantage of the new features of EF including full support of storedprocedures then you want to look at EF 6 instead: Entity Framework Code First and Stored Procedures[^]
 
Share this answer
 
Comments
#realJSOP 27-Mar-19 20:35pm    
Ef6 does not have “full support” for stored procs. Ask me how I know.
Vincent Maverick Durano 27-Mar-19 22:05pm    
That's good to know. Well I don't really use EF to drive SPs but I'm glad you bring this up :) Atleast EF6 has better support for SPs compared to previous versions. :)
The easiest way - setup your own database, import the data into it (using the customer's stored procedures to acquire the data), and then write EF models to load it from YOUR database.

EF will NOT be able to properly define models from datasets *returned by stored procs* that are selected from temp tables, or (it appears) dynamic sql. If you're using EF6 or earlier, don't hold your breath waiting for a fix from MS. They're not at all interested in maintaining anything older than EF7 (.Net Core).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900