azure - SQL to Entity Framework -


i'm using azure sql database , entity framework performing database operations on it.

how can convert sql query entity framework ?

begin tran set transaction isolation level serializable go  select top 1 * employee (updlock) empid = @id;  ......  commit 

i want lock row other threads when thread reading , perform operation on it.

i cannot use stored procedures i'm using azure sql database.

i don't know why not use stored procedure this. marc_s mentioned azure sql db supports stored procedures. said can execute query ef if want. ef not support specifying query hints linq queries, easiest use raw sql execution apis. using ef6:

using (var context = new mycontext())  {    using (var transaction = context.database.begintransaction())    {      try      {        var employee = context.employees.sqlquery(         "select top 1 * employee (updlock) empid = @id", id);       // ...       transaction.commit();      }      catch (exception)      {        transaction.rollback();      }    }  }  

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -