c# - IDENT_CURRENT in Linq-to-Entities
I am using Linq-to-Entities in my Windows Application and want to execute this SQL statement:
SELECT IDENT_CURRENT ('ProductInfo') AS Current_Identity
I have read another post that is using Database.SqlQuery
like this:
int varMaxAdvertiseId = Convert.ToInt32(hmd.Database.SqlQuery<decimal>("Select IDENT_CURRENT ('HMDAdvertiseManage')", new object[0]).FirstOrDefault());
but this is not working with me (intelisense is not showing it) Can someone help me, please ?
Solution 1:
var id = hmd.ExecuteStoreQuery<decimal>(@"SELECT IDENT_CURRENT ({0}) AS Current_Identity;",
"HMDAdvertiseManage").First();