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
Post a Comment