In the Entity Framework designer, I noticed that you can map stored procedures for Insert, Update, and Delete operations. Is there a way to do this for Select operations, and is there also a new direction for the database access code in which we no longer write stored procedures for our main selection operations?
The company I'm working on is pretty adamant about using stored procedures for every database operation, even though the Entity Framework makes calls safe by calling sp_executesql.
It seems that both LINQ to SQL and Entity Framework have moved away from using stored procedures to select data. Is this an exact statement?
To clarify my question:
I have a table in my database called Product. I use the wizard in the Entity Framework to create my models ... so I now have an Entity called Product. When I make the following request:
db.Products.SingleOrDefault(p => p.Id == 1);
It generates code similar to:
EXEC sp_executesql N'SELECT * FROM Product'
When I really want to do something like:
EXEC up_GetProduct @Id = 1
If this cannot be done using SingleOrDefault, I'm fine. I would prefer the following:
db.Products.GetProduct(1);
Is this something that is usually done or is most people just dynamically generating SQL?
source share