I am new to Linq and previously have been using Ado.net classes.
I want to use Linq-to-SQL with stored procedures. can you please share code (or link of code) of a generic class to call different stored procedures. I dont want to make separate DAL classes/ methods for every database entity.
Thanks
In the case of generics, you would presumably be limited to basic CRUD operations. In which case, you should be able to to use the table:
(and update should work for entities that have been changed, using the SPROC that you have specified for updates).
the
SubmitChangeswill then use the correct sprocs automatically (you can specify a SPROC for insert, update and delete in the designer or the DBML. The tricky bit is the get. That is not exposed directly on the ctx… The only suggestion I have their is a name-based pattern on the data-context and reflection? So maybe aGetFoomethod for getting aFoo.Another approach, of course, is to implement multiple generic interfaces, i.e.
(which extends the data-context)
Then you could cast the data-context: