[TestMethod] public void QueryListForSQLTest() { using (IUnitOfWork unitOfWork = GetUnitOfWork()) { var commonRepo = unitOfWork.GetRepositoryForEntity<UserInfo>(); var dto = commonRepo.GetList("select * from userinfo where NiceName like @NiceName ", new { NiceName ="%小潮%" });
foreach (var item in dto) { Console.WriteLine(item.NiceName); } } }
查询 For 对象 属性 :
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[TestMethod] public void QueryListTest() { using (IUnitOfWork unitOfWork = GetUnitOfWork()) { var commonRepo = unitOfWork.GetRepositoryForEntity<UserInfo>(); var predicate = Predicates.Field<UserInfo>(f => f.NiceName, Operator.Like, "%小潮%"); var dto = commonRepo.GetList(predicate); foreach (var item in dto) { Console.WriteLine(item.NiceName); } } }