auto generate in LINQ to SQL -


I have a table that has 2 columns, IDs and names set to 'yes' identity for the I id column.

I want to insert the data in the table, LINQ. I want to get only the name column from the user in my application, and then I want to fill the id column database automatically and I can not give the data that fills the column and I fill it in the whistle.

What should I do?

I write in C # and I work for LINQ.

Then your database field already has an INT identity - okay?

Next, from your LINQ to SQL designer, you need to make sure that your column is set to:

  • Auto-generated value = TRUE
  • Auto-sync = INSERT

Now if you add your entry database, please update the ID automatically with the value assigned by the database Will be given:

  YourClass instance = new YourClass (); Examples. Name = "some name"; YourDataContext.InsertOnSubmit (example); YourDataContext.SubmitChanges ();  

After the submit changelog call, your instance.ID should now have an ID from the database.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -