using LinqToDB;
using System;
using System.Linq;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
using (var db = new TestDB())
{
//Insert
db.Insert(new UserTB() { Name = "张三", Age = 20 });
var id = db.InsertWithInt32Identity(new UserTB() { Name = "李四", Age = 30 });
//Update
var user1 = db.UserTbs.FirstOrDefault();
user1.Name += "new";
db.Update(user1);
//Delete
var user2 = db.UserTbs.OrderByDescending(item => item.Id).FirstOrDefault(); //不支持方法LastOrDefault
db.Delete(user2);
//db.UserTbs.Where(item => item.Id == id).Delete();
//Select
var users = db.UserTbs.ToList();
foreach (var item in users)
{
Console.WriteLine("{0},{1},{2}", item.Id, item.Name, item.Age);
}
}
Console.ReadLine();
}
}
}