c# - Entity Framework 6 Mixed Stored Procedure and SQL Query Generation -


reading ef documentation on codeplex understand it's not possible use both mixture of stored procedure , sql query generation persisting domain model changes.

however, there numerous reasons why find frustrating doesn't allow me use mixture of both when predecessor - linq 2 sql, allowed me this.

i have complicated scenario persisting domain model multiple tables in database, whereby want use stored procedure insertion. reason why don't want use stored procedure updates there isn't clean way run update on columns affected - parsing values update sproc have update fields record (unless select old values again comparison or include fields in update statement predicate clause - kind of messy both ways). problem due triggers being attached table in individual fields checked updates, more of legacy system issue - won't go down road of subjective matter of using triggers being design.

passing fields update sproc if haven't changed unnecessary , can contribute network traffic, whereas ef knows fields explicitly update when using sql query generation mode.

are there entity framework add-ons allow me use mixture of stored procedure mapping inserts, , sql query generation updates model persistency?

for database using sql server, believe suitable add-on wouldn't coupled chosen data store.

you can call stored procedure (if in database), or can write query , execute it.

i'm not on laptop visual studio should work this:

  list<ekipa> result = new list<ekipa>();         dataset ds = new dataset();         using (userscontext uc = new userscontext())         {             using (sqlconnection con = new sqlconnection(uc.database.connection.connectionstring))             {                 con.open();                  sqlcommand com = new sqlcommand("procedurename", con);                 com.commandtype = commandtype.storedprocedure;                  command.parameters.addwithvalue("@id", 12);                 using (sqldataadapter da = new sqldataadapter(com))                 {                     da.fill(ds);                 }             }         }          result = (from myrow in ds.tables[0].asenumerable()                   select new ekipa()                   {                       userid = myrow.field<int>("userid"),                       username = myrow.field<string>("username"),                       bodovi = myrow.field<int>("bod"),                       ou = myrow.field<int>("ou"),                       gol = myrow.field<int>("postignutigolovi"),                   }).tolist(); 

just enable multiple multipleactiveresultsets in config

<add name="defaultconnection" connectionstring="data source=**.**.***.***;initial catalog=**;user id=**_dbuser; password=***; multipleactiveresultsets=true; " providername="system.data.sqlclient" /> 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -