If possible I would like to increment a number on the application side and save to the database using c# and Linq.
So for example I have a table like so:
|id|text|version|
-----------------
1 hello 1
2 hello 1
When inserting a new record into this table I want to get the current version number and increment by 1 then insert a new row
|id|text|version|
-----------------
1 hello 1
2 hello 1
1 hello 2
I can do a standard insert using linq but obviously stuck with what to do with the version
DataContext db = new DataContext
using (db)
{
table t = new table
{
text = TextBox1.Text
version = ??
};
db.table.InsertOnSubmit(t);
db.SubmitChanges();
}
Can I somehow select the row and get the current version number and then just increment by 1? Or should I just re-think my approach?
Thanks
versioncolumn in the database itself.IDENTITY.