Question

So I have a customer requirement to only use stored procedures for all database operations. I created CRUD stored procedures for each of my tables, and then created my Entity models.

So I see easily how to map my Insert, Update and Delete stored procedures to my entity (Customer for example), but there seems to be no way to map my Select? This is just a plain old select, it should just return a list of my Customer entities- so it maps directly to my Entity type, it is not custom. It seems the only way to do this is to import a function and map that instead.

So why no ability to map Select directly? There would be huge advantages for me to do this!

Maybe my stored procedure isn't suitable somehow?

Anyone have any ideas?

Was it helpful?

Solution

You would use the feature in EF that allows you to add stored procedures to the diagram and these become methods you can invoke directly. If you then open up the Model Browser, then track down the SELECT procedure(s) you added, you can double-click each one and bind the return type to the entity model. The calling convention would then be

MyEntity entity = myDB.MyStoredProcedure().FirstOrDefault();

HTH, Jon

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top