gistlib
To save records to a database using LinqToSQL in C#, you can follow these steps:
main.csstring connectionString = "your_connection_string"; DataContext db = new DataContext(connectionString); 104 chars3 lines
string connectionString = "your_connection_string"; DataContext db = new DataContext(connectionString);
main.csTable<YourTable> yourTable = db.GetTable<YourTable>(); 55 chars2 lines
Table<YourTable> yourTable = db.GetTable<YourTable>();
main.csYourTable record = new YourTable(); record.Property1 = value1; record.Property2 = value2; // and so on.. 105 chars5 lines
YourTable record = new YourTable(); record.Property1 = value1; record.Property2 = value2; // and so on..
main.csyourTable.InsertOnSubmit(record); 34 chars2 lines
yourTable.InsertOnSubmit(record);
main.csdb.SubmitChanges(); 20 chars2 lines
db.SubmitChanges();
gistlibby LogSnag