• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Where类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Where类属于命名空间,在下文中一共展示了Where类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: GetDisplayValues

        /// <summary>
        /// Define com as propriedades serão dispostas na grid
        /// </summary>
        /// <param name="where">Filtros a serem informados</param>
        /// <returns></returns>
        public override IDisplayValues GetDisplayValues(Where where = null)
        {
            IDisplayValues result = base.GetDisplayValues(where);
            result.Columns.Clear();
            result.Columns.Add(new Parameter("GUID", GenericDbType.String, "sis_log.guid"));
            result.Columns.Add(new Parameter("IP", GenericDbType.String, "sis_log.ip"));
            result.Columns.Add(new Parameter("Nome do computador", GenericDbType.String, "sis_log.nomemaquina"));
            result.Columns.Add(new Parameter("Data do evento", GenericDbType.Date, "sis_log.datahoraevento"));
            result.Columns.Add(new Parameter("Evento", GenericDbType.String, "sis_log.evento"));
            result.Columns.Add(new Parameter("MD5", GenericDbType.String, "sis_logibpt.md5"));
            result.Columns.Add(new Parameter("Caminho", GenericDbType.String, "sis_logibpt.caminho"));

            result.DynamicPaging = (w) =>
            {
                result = DbContext.GetDisplayValues(this, w);
                DataReader dataReader = result.DataReader;

                result.Values = (from x in dataReader
                                     select new object[]
                                     {
                                         x["p_GUID"],
                                         x["p_ip"],
                                         x["p_nomemaquina"],
                                         x["p_datahoraevento"],
                                         x["p_evento"],
                                         x["p_md5"],
                                         x["p_caminho"]
                                     }).ToList();
                return result;
            };

            return result;
        }
开发者ID:njmube,项目名称:openposbr,代码行数:38,代码来源:LogIBPTBase.cs


示例3: 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


示例4: Select

 public Select(Expression selectItem, From.From from, Where.Where where)
 {
     SelectList = new List<Expression>();
     SelectList.Add(selectItem);
     From = from;
     Where = where;
 }
开发者ID:jgshort,项目名称:SqlDom,代码行数:7,代码来源:Select.cs


示例5: GetDisplayValues

        public override IDisplayValues GetDisplayValues(Where where = null)
        {
            IDisplayValues result = DbContext.GetDisplayValues(this, where);
            result.Columns.Clear();
            result.Columns = new List<Parameter> {
                new Parameter {
                    ParameterName = "GUID"
                },
                new Parameter {
                    ParameterName = "Código",
                    SourceColumn = "EGUID",
                },
                new Parameter {
                    ParameterName = "Estado",
                    SourceColumn = "Nome",
                },
                new Parameter{
                ParameterName = "UF",
                SourceColumn = "UF"

                }
            };

            result.Values = (from x in result.DataReader
                             select new[]{
                                 x["p_GUID"],
                                 x["p_EGUID"],
                                 x["p_Nome"],
                                 x["p_UF"]
                             }).ToList();

            return result;
        }
开发者ID:njmube,项目名称:openposbr,代码行数:33,代码来源:Estado.cs


示例6: GetDisplayValues

        public override IDisplayValues GetDisplayValues(Where where = null)
        {
            IDisplayValues result = base.GetDisplayValues(where);
            result.Columns.Clear();
            result.Columns.Add(new Parameter("GUID", GenericDbType.String, "fat_Lan.GUID"));
            result.Columns.Add(new Parameter("Código", GenericDbType.String, "fat_LanMOVPV.EGUID"));
            result.Columns.Add(new Parameter("Cliente", GenericDbType.String, "fat_LanMovDadoPessoa.NomeFantasia"));
            result.Columns.Add(new Parameter("Valor", GenericDbType.String, "fat_LanMov.vlrtotalliquido"));

            result.DynamicPaging = (w) =>
            {
                result = DbContext.GetDisplayValues(this, w);
                DataReader dr = result.DataReader;

                result.Values = (from x in dr
                                 select new object[] {
                                 x["p_GUID"],
                                 x["p_EGUID"],
                                 x["p_DPNomeFantasia"],
                                 Unimake.Format.Currency(x["p_VlrTotalLiquido"])
                             }).ToList();

                return result;
            };

            return result;
        }
开发者ID:njmube,项目名称:openposbr,代码行数:27,代码来源:PreVenda.cs


示例7: CreateNewEvent

    private void CreateNewEvent()
    {
        //Set Event Entry
        Google.GData.Calendar.EventEntry oEventEntry = new Google.GData.Calendar.EventEntry();
        oEventEntry.Title.Text = "Test Calendar Entry From .Net for testing";
        oEventEntry.Content.Content = "Hurrah!!! I posted my second Google calendar event through .Net";

        //Set Event Location
        Where oEventLocation = new Where();
        oEventLocation.ValueString = "Mumbai";
        oEventEntry.Locations.Add(oEventLocation);

        //Set Event Time
        When oEventTime = new When(new DateTime(2012, 8, 05, 9, 0, 0), new DateTime(2012, 8, 05, 9, 0, 0).AddHours(1));
        oEventEntry.Times.Add(oEventTime);

        //Set Additional Properties
        ExtendedProperty oExtendedProperty = new ExtendedProperty();
        oExtendedProperty.Name = "SynchronizationID";
        oExtendedProperty.Value = Guid.NewGuid().ToString();
        oEventEntry.ExtensionElements.Add(oExtendedProperty);

        CalendarService oCalendarService = GAuthenticate();
        Uri oCalendarUri = new Uri("http://www.google.com/calendar/feeds/pankaj.sevlani[email protected]/private/full");

        //Prevents This Error
        //{"The remote server returned an error: (417) Expectation failed."}
        System.Net.ServicePointManager.Expect100Continue = false;

        //Save Event
        oCalendarService.Insert(oCalendarUri, oEventEntry);
    }
开发者ID:pank1982,项目名称:mydoc,代码行数:32,代码来源:GoogleTest.aspx.cs


示例8: Execute

 /// <summary>
 /// Instancia uma nova MappingEngine pelo nó definido no XML. Se o nó não existir será retornado um erro
 /// </summary>
 ///<param name="typeMapping">tipo que será mapeado pelo ETLMapping.xml</param>
 ///<param name="executing">Ação que deverá ser chamada ao executar algo</param>
 ///<param name="onEnd">Ação executada ao terminar a integração do registro</param>
 ///<param name="onStart">Ação executada ao iniciar a integração do registro</param>
 ///<param name="where">Filtro que será usado pelo select, se existir. Pode ser nulo</param>
 public void Execute(Type typeMapping,
         Action<ExecuteEventArgs> executing,
         Action<ExecuteEventArgs> onStart,
         Action<ExecuteEventArgs> onEnd,
         Where where)
 {
     Execute(typeMapping, executing, onStart, onEnd, "", where);
 }
开发者ID:njmube,项目名称:openposbr,代码行数:16,代码来源:MappingEngine.cs


示例9: ImportOrder

        /// <summary>
        /// Instancia este objeto e filtra pelo número do Pedido
        /// </summary>
        /// <param name="orderId"></param>
        public ImportOrder(string orderId)
        {
            Where = new Where();

            Where.Parameters.Add(new Parameter("@value", GenericDbType.String)
                {
                    Value = orderId
                });

            Tag = "Pedido";
        }
开发者ID:njmube,项目名称:openposbr,代码行数:15,代码来源:ImportOrder.cs


示例10: Target

        /// <summary>
        /// Create a new <see cref="Target"/>.
        /// </summary>
        /// <param name="expression">
        /// The <see cref="EffectExpression"/> this is part of. This cannot be null.
        /// </param>
        /// <param name="targetType">
        /// The actual target of the <see cref="EffectComponent"/>.
        /// </param>
        /// <param name="where">
        /// Where the target is, or null if that is unspecified.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///  <paramref name="expression"/> cannot be null.
        /// </exception>
        public Target(EffectExpression expression, TargetType targetType, Where where)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            this.Expression = expression;
            this.TargetType = targetType;
            this.Where = where;
        }
开发者ID:anthonylangsworth,项目名称:GammaWorldCharacter,代码行数:26,代码来源:Target.cs


示例11: Or_Expression

        public void Or_Expression()
        {
            var expr =
                    new Where<TestClass>().Like(x => x.A, "Alice").Or().SmallerThan(x => x.B, 2);

            var param = new Dictionary<string, object>();

            var sql = expr.Build(param).ToString();

            Assert.AreEqual(
                "WHERE [AA] LIKE @A OR [B]<@B",
                sql);

            Assert.AreEqual(2, param.Count);
        }
开发者ID:jbinder,项目名称:dragon,代码行数:15,代码来源:SqlBuilderTest.cs


示例12: And_Expression_2

        public void And_Expression_2()
        {
            var expr =
                new Where<TestClass>().Group(g => g.Like(x => x.A, "Alice").And().SmallerThan(x => x.B, 2));

            var param = new Dictionary<string, object>();

            var sql = expr.Build(param).ToString();

            Assert.AreEqual(
                "WHERE ([AA] LIKE @A AND [B]<@B)",
                sql);

            Assert.AreEqual(2, param.Count);
        }
开发者ID:jbinder,项目名称:dragon,代码行数:15,代码来源:SqlBuilderTest.cs


示例13: btnAdd_Click

        /// <summary>
        /// Handles the Click event of the btnAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try {
            int attributeId = 0;
            int attributeItemId = 0;
            int.TryParse(lblAttributeId.Text, out attributeId);
            int.TryParse(lblAttributeItemId.Text, out attributeItemId);
            AttributeItem attributeItem;
            if (attributeId > 0) {
              Where where = new Where();
              where.ColumnName = AttributeItem.Columns.AttributeId;
              where.DbType = DbType.Int32;
              where.ParameterValue = attributeId;
              Query query = new Query(AttributeItem.Schema);
              object strSortOrder = query.GetMax(AttributeItem.Columns.SortOrder, where);
              int maxSortOrder = 0;
              int.TryParse(strSortOrder.ToString(), out maxSortOrder);

              if (attributeItemId > 0) {
            attributeItem = new AttributeItem(attributeItemId);
              }
              else {
            attributeItem = new AttributeItem();
            attributeItem.SortOrder = maxSortOrder + 1;
              }

              attributeItem.AttributeId = attributeId;
              attributeItem.Name = Server.HtmlEncode(txtAttributeItemName.Text.Trim());
              decimal adjustment = 0;
              decimal.TryParse(txtAdjustment.Text, out adjustment);
              attributeItem.Adjustment = adjustment;
              if (!string.IsNullOrEmpty(txtSkuSuffix.Text)) {
            attributeItem.SkuSuffix = txtSkuSuffix.Text;
              }
              else {
            attributeItem.SkuSuffix = CoreUtility.GenerateRandomString(3);
              }

              attributeItem.Save(WebUtility.GetUserName());
              LoadAttributeItems();
              ResetAttributeItem();
            }
              }
              catch (Exception ex) {
            Logger.Error(typeof(attributeedit).Name + ".btnAdd_Click", ex);
            Master.MessageCenter.DisplayCriticalMessage(ex.Message);
              }
        }
开发者ID:freecin,项目名称:dashcommerce-3,代码行数:53,代码来源:attributeedit.aspx.cs


示例14: Complex_Expression_1

        public void Complex_Expression_1()
        {
            var expr =
                    new Where<TestClass>().IsEqual(x => x.A, "Bob")
                        .And(g => g.Like(x => x.B, "Alice").Or().SmallerThan(x => x.C, 2))
                        .And(g => g.GreaterThanOrEqualTo(x => x.C, 3).Or().IsEqual(x => x.D, "Chris"));

            var param = new Dictionary<string, object>();

            var sql = expr.Build(param).ToString();

            Assert.AreEqual(
                "WHERE [AA][email protected] AND ([B] LIKE @B OR [CC]<@C) AND ([CC]>[email protected] OR [D][email protected])",
                sql);

            Assert.AreEqual(5, param.Count);
        }
开发者ID:jbinder,项目名称:dragon,代码行数:17,代码来源:SqlBuilderTest.cs


示例15: SintegraReg60M

        /// <summary>
        /// Instancia este objeto e carrega o mesmo com os dados de número de série e data informados
        /// <param name="dataEmissao">Data de emissão do documentos</param>
        /// <param name="numeroSerie">Número de série do ECF</param>
        /// </summary>
        public SintegraReg60M(DateTime dataEmissao, string numeroSerie)
            : this()
        {
            Where w = new Where {
                { "DataEmissao = @p1", new Parameter{
                    ParameterName = "@p1",
                    Value = dataEmissao ,
                    GenericDbType = GenericDbType.Date}
                },

                { "NumSerie = @p2", new Parameter{
                    ParameterName = "@p2",
                    Value = numeroSerie}
                }
            };

            DbContext.Populate(this, w);
        }
开发者ID:njmube,项目名称:openposbr,代码行数:23,代码来源:SintegraReg60M.cs


示例16: AreaBurst

        /// <summary>
        /// Close burst n (where N is a positive integer).
        /// </summary>
        /// <param name="powerName">
        /// The <see cref="Power"/> this is for. This cannot be null or empty.
        /// </param>
        /// <param name="size">
        /// The size of the burst in squares. This must be positive.
        /// </param>
        /// <param name="where">
        /// Where the burst occurs. This cannot be null.
        /// </param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// Neither <paramref name="powerName"/> nor <paramref name="where"/> can be null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="size"/> must be positive.
        /// </exception>
        public static AttackTypeAndRange AreaBurst(string powerName, int size,  Where where)
        {
            if (string.IsNullOrEmpty(powerName))
            {
                throw new ArgumentNullException("powerName");
            }
            if (where == null)
            {
                throw new ArgumentNullException("where");
            }
            if (size <= 0)
            {
                throw new ArgumentException("range must be positive", "size");
            }

            return new AttackTypeAndRange(powerName, AttackType.Area,
                "burst " + size.ToString() + " " + where.ToString().ToLower());
        }
开发者ID:anthonylangsworth,项目名称:GammaWorldCharacter,代码行数:37,代码来源:Range.cs


示例17: GetDisplayValues

        public override IDisplayValues GetDisplayValues(Where where = null)
        {
            IDisplayValues result = DbContext.GetDisplayValues(this, where);
            DataReader dataReader = result.DataReader;

            result.Columns.Add("GUID");
            result.Columns.Add("EGUID");
            result.Columns.Add("Nível");
            result.Columns.Add("Descricao");

            result.Values = (from x in dataReader
                             select new object[] {
                                        x["p_GUID"],
                                        x["p_EGUID"],
                                        x["p_Nivel"],
                                        x["p_Descricao"]}).ToList();

            return result;
        }
开发者ID:njmube,项目名称:openposbr,代码行数:19,代码来源:NivelAcesso.cs


示例18: Query_SelectTop

        public void Query_SelectTop()
        {
            Where LikeUnitTestTerritory = new Where();
            LikeUnitTestTerritory.TableName = Territory.Schema.TableName;
            LikeUnitTestTerritory.ColumnName = Territory.Columns.TerritoryDescription;
            LikeUnitTestTerritory.Comparison = Comparison.Like;
            LikeUnitTestTerritory.ParameterValue = "%ville%";

            Query qry = new Query(Territory.Schema);
            qry.Top = "3";
            qry.AddWhere(LikeUnitTestTerritory);
            int counter = 0;

            using(IDataReader rdr = qry.ExecuteReader())
            {
                while(rdr.Read())
                    counter++;
                rdr.Close();
            }
            Assert.AreEqual(3, counter, "Count is " + counter);
        }
开发者ID:BlackMael,项目名称:SubSonic-2.0,代码行数:21,代码来源:QueryTest.cs


示例19: Find

        public Model[] Find(Where.Where where)
        {
            var data = DBMS.DB.GetInstance().Find(_tableName, where);

            var list = new List<Model>();
            foreach (var row in data)
            {
                var obj = (Model)Activator.CreateInstance(_type);
                obj.Id = Convert.ToInt64(row.Get("id"));
                foreach (var fieldData in _dbField)
                {
                    if(fieldData.GetField() is CharField)
                        fieldData.GetInfo().SetValue(obj, row.Get(fieldData.GetInfo().Name.ToLower()));
                    else if(fieldData.GetField() is Int64Field)
                        fieldData.GetInfo().SetValue(obj, Convert.ToInt64(row.Get(fieldData.GetInfo().Name.ToLower())));
                }
                list.Add(obj);
            }

            return list.ToArray();
        }
开发者ID:shlee322,项目名称:Netronics,代码行数:21,代码来源:Raw.cs


示例20: btnSave_Click

 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if(Page.IsValid){
     try {
       string descriptorId = lblDescriptorId.Text;
       Descriptor descriptor;
       Where where = new Where();
       where.ColumnName = Descriptor.Columns.ProductId;
       where.DbType = DbType.Int32;
       where.ParameterValue = productId;
       Query query = new Query(Descriptor.Schema);
       object strSortOrder = query.GetMax(Descriptor.Columns.SortOrder, where);
       int maxSortOrder = 0;
       int.TryParse(strSortOrder.ToString(), out maxSortOrder);
       if(!string.IsNullOrEmpty(descriptorId)) {
     descriptor = new Descriptor(descriptorId);
       }
       else {
     descriptor = new Descriptor();
     descriptor.SortOrder = maxSortOrder + 1;
       }
       descriptor.ProductId = productId;
       descriptor.Title = txtTitle.Text.Trim();
       descriptor.DescriptorX = HttpUtility.HtmlEncode(txtDescriptor.Value.Trim());
       descriptor.Save(WebUtility.GetUserName());
       Store.Caching.ProductCache.RemoveDescriptorCollectionFromCache(productId);
       LoadDescriptors();
       lblDescriptorId.Text = string.Empty;
       txtTitle.Text = string.Empty;
       txtDescriptor.Value = string.Empty;
       base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblDescriptorSaved"));
     }
     catch(Exception ex) {
       Logger.Error(typeof(descriptors).Name + "btnSave_Click", ex);
       base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
       }
 }
开发者ID:montyclift,项目名称:dashcommerce-3,代码行数:43,代码来源:descriptors.ascx.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WhereClause类代码示例发布时间:2022-05-24
下一篇:
C# WellKnownType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap