首页 > 代码库 > LinqToSql

LinqToSql

string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConsoleApp55.Properties.Settings.mydbConnectionString"].ToString();
ConsoleApp55.DataClasses1DataContext db = new DataClasses1DataContext(connectionString);

mt2 mymt = new mt2();
mymt.id = Guid.NewGuid();
mymt.name = "SLJ";

db.mt2s.InsertOnSubmit(mymt);
db.SubmitChanges();

mt2 secondMt = db.mt2s.FirstOrDefault(x => x.name.Equals("SLJ"));

Console.WriteLine("Id={0},Name={1}", secondMt.id, secondMt.name);
Console.ReadLine();

LinqToSql