当前位置: 首页>>代码示例>>C#>>正文


C# Where.And方法代码示例

本文整理汇总了C#中Where.And方法的典型用法代码示例。如果您正苦于以下问题:C# Where.And方法的具体用法?C# Where.And怎么用?C# Where.And使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Where的用法示例。


在下文中一共展示了Where.And方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUser

        /// <summary>
        /// 获取数据。此数据会持续增长,所以不建议一次性缓存。建议单个Model实体缓存。
        /// </summary>
        public BaseResult GetUser(TestTableParam param)
        {
            var where = new Where<TestTable>();
            #region 模糊搜索条件
            if (!string.IsNullOrWhiteSpace(param.SearchName))
            {
                where.And(d => d.Name.Like(param.SearchName));
            }
            if (!string.IsNullOrWhiteSpace(param.SearchIDNumber))
            {
                where.And(d => d.IDNumber.Like(param.SearchIDNumber));
            }
            if (!string.IsNullOrWhiteSpace(param.SearchMobilePhone))
            {
                where.And(d => d.MobilePhone.Like(param.SearchMobilePhone));
            }
            #endregion

            #region 是否分页
            var dateCount = 0;
            if (param._PageIndex != null && param._PageSize != null)
            {
                //取总数,以计算共多少页。自行考虑将总数缓存。
                dateCount = TestTableRepository.Count(where);//.SetCacheTimeOut(10)
            }
            #endregion
            var list = TestTableRepository.Query(where, d => d.CreateTime, "desc", null, param._PageSize, param._PageIndex);
            return new BaseResult(true, list, "", dateCount);
        }
开发者ID:JackWangCUMT,项目名称:Dos.ORM,代码行数:32,代码来源:TestTableLogic.cs

示例2: GetUser

 /// <summary>
 /// 获取数据。
 /// </summary>
 public BaseResult GetUser(TestTableParam param)
 {
     var where = new Where<TestTable>();
     #region 模糊搜索条件
     if (!string.IsNullOrWhiteSpace(param.SearchName))
     {
         where.And(d => d.Name.Like(param.SearchName));
     }
     if (!string.IsNullOrWhiteSpace(param.SearchIDNumber))
     {
         where.And(d => d.IDNumber.Like(param.SearchIDNumber));
     }
     if (!string.IsNullOrWhiteSpace(param.SearchMobilePhone))
     {
         where.And(d => d.MobilePhone.Like(param.SearchMobilePhone));
     }
     #endregion
     var fs = DB.Context.From<TestTable>()
         .Where(where)
         .OrderByDescending(d => d.CreateTime);
     #region 是否分页
     var dateCount = 0;
     if (param.pageIndex != null && param.pageSize != null)
     {
         //取总数,以计算共多少页。自行考虑将总数缓存。
         dateCount = fs.Count();//.SetCacheTimeOut(10)
         fs.Page(param.pageSize.Value, param.pageIndex.Value);
     }
     #endregion
     var list = fs.ToList();
     return new BaseResult(true, list, "", dateCount);
 }
开发者ID:SaintLoong,项目名称:Dos.ORM,代码行数:35,代码来源:TestTableLogic.cs

示例3: GetUser

        /// <summary>
        /// 获取数据。
        /// </summary>
        public BaseResult GetUser(TestTableParam param)
        {
            #region 测试子查询修改
            //var model = new TestTable
            //{
            //    IDNumber = "XXXXXXXXXX"
            //};
            //var count2 = DB.MySql.Update<TestTable>(model, TestTable._.Id.SubQueryIn(
            //    DB.MySql.From<TestTable>().Select(d => d.Id).Where(d => d.IDNumber == "777")
            //));
            ////以上同Sql语句:
            ////update TestTable  set IDNumber='XXXXXXX' where Id in 
            ////              (SELECT Id from TestTable where IDNumber='777')
            #endregion
            #region 测试批量Save
            //var listModel = new List<TestTable>();
            //var model1 = new TestTable()
            //{
            //    Id = Guid.NewGuid(),
            //    IDNumber = "0000",
            //    CreateTime = DateTime.Now,
            //    MobilePhone = "000",
            //    Name = "00000"
            //};
            //var model2 = new TestTable()
            //{
            //    Id = Guid.Parse("fdc87fad-0e80-49b2-aab0-c52d1fcd1297"),
            //    IDNumber = "000",
            //    CreateTime = DateTime.Now,
            //    MobilePhone = "000",
            //    Name = "00000"
            //};
            //var model3 = new TestTable()
            //{
            //    Id = Guid.Parse("68805e30-5bc4-43ae-8ad7-8464be215e69")
            //};
            //model1.Attach(EntityState.Added);
            //model2.Attach(EntityState.Modified);
            //model3.Attach(EntityState.Deleted);
            //listModel.Add(model1);
            //listModel.Add(model2);
            //listModel.Add(model3);
            //var count = DB.MySql.Save<TestTable>(listModel);
            #endregion
            var where = new Where<TableMysql>();
            #region 模糊搜索条件
            if (!string.IsNullOrWhiteSpace(param.SearchName))
            {
                where.And(d => d.Name.Like(param.SearchName));
            }
            if (!string.IsNullOrWhiteSpace(param.SearchIDNumber))
            {
                where.And(d => d.IDNumber.Like(param.SearchIDNumber));
            }
            if (!string.IsNullOrWhiteSpace(param.SearchMobilePhone))
            {
                where.And(d => d.MobilePhone.Like(param.SearchMobilePhone));
            }
            #endregion
            #region test
            var tempFs = DB.MySql.From<TableMysql>()
                .Select(TableMysql._.Id)
                .Select(TableMysql._.Name)
                .Select(d=>d.MobilePhone)
                .Where(d=>d.Id == Guid.NewGuid())
                .Where(d=>d.Name != "zhouhao")
                .OrderByDescending(d => d.CreateTime)
                .OrderBy(d => d.Id)
                .GroupBy(d => new { d.Id, d.Name })
                .GroupBy(TableMysql._.Id, TableMysql._.Test1)
                .ToList();
            var tempFs2 = DB.MySql.From<TableMysql>()
                .Select(TableMysql._.Id)
                .Select(TableMysql._.Test1)
                .Select(d => d.Test2)
                .Where(d => d.Test1 == false)
                .Where(d => d.Test2 != 333)
                .OrderByDescending(d => d.Name)
                .OrderBy(d => d.Id)
                .ToList();
            #endregion

            var fs = DB.MySql.From<TableMysql>()
                .Where<TableMysql>((a,b)=>a.Id == Guid.NewGuid() && b.IDNumber == "11")
                //.OrderByDescending(TableMysql._.CreateTime, TableMysql._.Id)
                //.OrderByDescending(d => new { d.CreateTime, d.Id });
                .OrderByDescending(d => d.CreateTime)
                .OrderBy(d => d.Id);
            #region 是否分页
            var dateCount = 0;
            if (param._PageIndex != null && param._PageSize != null)
            {
                //取总数,以计算共多少页。自行考虑将总数缓存。
                dateCount = fs.Count();//.SetCacheTimeOut(10)
                fs.Page(param._PageSize.Value, param._PageIndex.Value);
            }
            #endregion
//.........这里部分代码省略.........
开发者ID:szp11,项目名称:Dos.ORM,代码行数:101,代码来源:TableMySqlLogic.cs


注:本文中的Where.And方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。