c# - In LinqToSql, is it possible to have a custom Insert method that Auto-Syncs the primary key? -
I can do this if I leave the organization's insertion method as 'Use Runtime' and it is directly I work to get involved, but I have to use a SP.
I have just tried to return the @@ identity to the SML server and then assign it to the ID, but due to this a change becomes the reason for the notification and LinqToSql thinks that it has changed, Even if it is the only id.
So basically I need a way to enter the primary key without inserting it through an alert without entering any spam.
Is it possible, if so?
Thank you.
A solution works for me SP is a partial method to call your DataContext
is called InsertEntity
(where unit is the name of your class. In this method you will need to manually call your SP, but then you You can map the value of your unit's properties, and Linux SQL will respect this.
For example:
Public Partial Category YourDat AContext {partial null your unit (your entity unit) {using (DbCommand cmd = this.Connection.CreateCommand ()) {... // parameter and the name of SP set here cmd.ExecuteNonQuery (); entity.Id = (Int) Some Parameter.Value;}}}
Note that this will not be any idling
or identifed
event Press (as it changed, and the database can depend on a proper information). However, by entering submit changelog
, do not include not
After a update
, another submit
unit will not be seen changing.
Comments
Post a Comment