按条件查询

--根据主键Id查询数据

T model = ORM.Get<T>(tblDemo.Id);

--

--根据兰姆达表达式查询数据

List<T> list = ORM.Get<T>((it => it.Where(o => o.Mark > 0).OrderBy(o => o.CreateDate)));

--

--根据兰姆达表达式查询数据(In): where id in(3, 5, 10)

string[] ids = new string[]{"3", "5", "10"};

List<int> listIds = ids.ToList();

用法1:List<T> list = ORM.Get<T>((it => it.Where(o => o.Id.In(ids))));

用法2:List<T> list = ORM.Get<T>((it => it.Where(o => o.Id.In(listIds))));

用法3:List<T> list = ORM.Get<T>((it => it.Where(o => o.Id.In(1, 2, 3, 5, 6))));

--

--根据兰姆达表达式查询数据(Like)

List<T> list = ORM.Get<T>((it => it.Where(o => o.Id.Like("abc%"))));

--

--根据Sql条件查询数据(传入值参数化)

--写法1

List<T> list = ORM.GetWhere<T>("where ClassID = @ClassID and Mark > 0", "order by CreateDate"

           , new { ClassID = "1" });

--写法2

var paramList = new List<MKeyValue>();

paramList.Add("@ClassID", "1");

List<T> list = ORM.GetWhere<T>("where ClassID = @ClassID and Mark > 0", "order by CreateDate"

           , paramList);