sqlsugar的简单尝试
class Program
{
static void Main(string[] args)
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString =Config.ConnectionString,
DbType = DbType.MySql,//设置数据库类型
IsAutoCloseConnection = true,//自动释放数据务,如果存在事务,在事务结束后释放
InitKeyType = InitKeyType.Attribute //从实体特性中读取主键自增列信息
});
var list_2 = db.Queryable<users>().Where(it=>it._name=="李四").ToList();
var list = db.Queryable<users>().First();
var num = list._name;
foreach(users users in list_2)
{
Console.WriteLine(users._url);
}
Console.WriteLine(num);
Console.ReadKey();
}
}
亮点在实体类中可以写Attribute标签,灵活映射表