c# - NEWID() SQL Server Function in Entity Framework -
i developing web application using angularjs, asp.net, entity framework , sql server database.
i want insert rows using ef method :
public string addrow(int captionid, string enlang) { string output = ""; try { var cap = new table_name(); string username = system.security.principal.windowsidentity.getcurrent().name; cap.codeid = captionid; cap.created = datetime.now; cap.createdby = username; cap.id = ""; cap.codelanguage = "en"; cap.codecountry = "gb"; cap.caption = enlang; _db.entry(cap).state = entitystate.added; _db.savechanges(); output = "created"; } catch (exception ex) { output = ex.innerexception.message; } return output; }
this function works.
but have question newid()
function, have searched lot know how reproduce same didn't knew, i've looked thread nothing.
in fact, want assign newid()
cap.id
.
p.s : know possible using sqlserver assigning select newid()
cap.id
, looking way using ef.
just do: cap.id = guid.newguid();
Comments
Post a Comment