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


C# FilterExpression类代码示例

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


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

示例1: When_executing_a_query_expression_with_2_filters_combined_with_an_or_filter_right_result_is_returned

        public void When_executing_a_query_expression_with_2_filters_combined_with_an_or_filter_right_result_is_returned()
        {
            var context = new XrmFakedContext();
            var contact1 = new Entity("contact") { Id = Guid.NewGuid() }; contact1["fullname"] = "Contact 1"; contact1["firstname"] = "First 1";
            var contact2 = new Entity("contact") { Id = Guid.NewGuid() }; contact2["fullname"] = "Contact 2"; contact2["firstname"] = "First 2";

            context.Initialize(new List<Entity>() { contact1, contact2 });

            var qe = new QueryExpression() { EntityName = "contact" };
            qe.ColumnSet = new ColumnSet(true);
            

            var filter1 = new FilterExpression();
            filter1.AddCondition(new ConditionExpression("fullname", ConditionOperator.Equal, "Contact 1"));

            var filter2 = new FilterExpression();
            filter2.AddCondition(new ConditionExpression("fullname", ConditionOperator.Equal, "Contact 2"));

            qe.Criteria = new FilterExpression(LogicalOperator.Or);
            qe.Criteria.AddFilter(filter1);
            qe.Criteria.AddFilter(filter2);

            var result = XrmFakedContext.TranslateQueryExpressionToLinq(context, qe).ToList();

            Assert.True(result.Count == 2);
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:26,代码来源:FilterExpressionTests.cs

示例2: BrowseGenres

        private HttpResponse BrowseGenres()
        {
            var filter = new FilterExpression<ITrack>(Request.QueryString["filter"]);
            var includeSortHeaders = "1".Equals(Request.QueryString["include-sort-headers"]);

            using (Player.MediaLibrary.BeginRead())
            {
                var rawItems = filter.Filter(Player.MediaLibrary.Tracks);

                var items = rawItems.Where(x => !string.IsNullOrEmpty(x.GenreName))
                                    .GroupBy(x => x.GenreName, StringComparer.InvariantCultureIgnoreCase)
                                    .Select(x => x.Key)
                                    .OrderBy(x => x, LatinFirstSortComparer.Instance)
                                    .ToArray();

                return new DmapResponse(new
                {
                    abro = new
                    {
                        mstt = 200,
                        muty = (byte)0,
                        abgn = items,
                        mshl = includeSortHeaders ? items.GetShortcuts(x => x) : null
                    }
                });
            }
        }
开发者ID:pieceofsummer,项目名称:TouchRemote,代码行数:27,代码来源:DatabaseInstanceResponder.Browse.cs

示例3: Translate

        public virtual Expression Translate(FilterExpression filter)
        {
            Expression result;

            switch (filter.ExpressionType)
            {
                case FilterExpressionType.Constant:
                    result = TranslateConstant((ConstantFilterExpression) filter);
                    break;
                case FilterExpressionType.Unary:
                    result = TranslateUnary((UnaryFilterExpression)filter);
                    break;
                case FilterExpressionType.Binary:
                    result = TranslateBinary((BinaryFilterExpression)filter);
                    break;
                case FilterExpressionType.MethodCall:
                    result = TranslateMethodCall((MethodCallFilterExpression)filter);
                    break;
                case FilterExpressionType.MemberAccess:
                    result = TranslateMemberAccess((MemberAccessFilterExpression)filter);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return result;
        }
开发者ID:chrisblock,项目名称:LinqToRest,代码行数:27,代码来源:FilterExpressionTranslator.cs

示例4: Build

        private IEnumerable<HistoryItem> Build(HistoryRequest request, Action<ClarifyGeneric, WorkflowObjectInfo> genericAction)
        {
            var clarifyDataSet = _session.CreateDataSet();

            var workflowObjectInfo = WorkflowObjectInfo.GetObjectInfo(request.WorkflowObject.Type);
            var workflowGeneric = clarifyDataSet.CreateGenericWithFields(workflowObjectInfo.ObjectName);
            if (workflowObjectInfo.HasIDFieldName)
            {
                workflowGeneric.DataFields.Add(workflowObjectInfo.IDFieldName);
            }

            genericAction(workflowGeneric, workflowObjectInfo);

            var inverseActivityRelation = workflowObjectInfo.ActivityRelation;
            var activityRelation = _schemaCache.GetRelation("act_entry", inverseActivityRelation).InverseRelation;

            var actEntryGeneric = workflowGeneric.Traverse(activityRelation.Name);
            actEntryGeneric.AppendSort("entry_time", false);

            if (request.Since.HasValue)
            {
                var filter = new FilterExpression().MoreThan("entry_time", request.Since.Value);
                actEntryGeneric.Filter.AddFilter(filter);
            }

            var templateDictionary = _templatePolicyConfiguration.RenderPolicies(request.WorkflowObject);

            //query generic hierarchy and while using act entry templates transform the results into HistoryItems
            return _historyItemAssembler.Assemble(actEntryGeneric, templateDictionary, request);
        }
开发者ID:modulexcite,项目名称:dovetail-bootstrap,代码行数:30,代码来源:HistoryBuilder.cs

示例5: GetAccountReferenceByNameFuzzy

        public static EntityReference GetAccountReferenceByNameFuzzy(this IOrganizationService service, string companyName)
        {
            var name = CompanyNameHelper.RemoveCommonCompanySuffixes(companyName);
            var nameCondition = ConditionExpressionHelper.CreatePublisherNameBeginsWithCondition(name);

            var filter = new FilterExpression();
            filter.Conditions.Add(nameCondition);

            var query = new QueryExpression(Account.EntityLogicalName);
            query.Criteria.AddFilter(filter);

            var accounts = service.RetrieveMultiple(query).Entities;

            if (accounts.Count() > 1)
            {
                throw new CrmAmbiguousMatchException(
                    string.Format("Found multiple fuzzy matches when searching for {0}.  Fuzzy match search: {1}", companyName, name));
            }

            var account = accounts.FirstOrDefault();
            if (account == null)
            {
                throw new CrmEntityNotFoundException("Account not found with name: " + companyName);
            }

            return new EntityReference(Account.EntityLogicalName, account.Id);
        }
开发者ID:hydr,项目名称:VcardCrmImporter,代码行数:27,代码来源:OrganizationServiceExtensions.cs

示例6: GetCompanyReferenceById

        public static EntityReference GetCompanyReferenceById(this IOrganizationService service, string companyName)
        {
            var compayNameCondition = ConditionExpressionHelper.CreateCompanyNameCondition(companyName);
            var filter = new FilterExpression();
            filter.Conditions.Add(compayNameCondition);

            var query = new QueryExpression(Account.EntityLogicalName)
            {
                ColumnSet = new ColumnSet(true)
            };

            query.Criteria.AddFilter(filter);

            var companies = service.RetrieveMultiple(query)
                .Entities.ToList();

            if (!companies.Any())
            {
                throw new CrmEntityNotFoundException(string.Format("Company '{0}' was not found.", companyName));
            }

            if (companies.Count > 1)
            {
                throw new CrmAmbiguousMatchException(string.Format("{0} companies found with name '{1}'.", companies.Count, companyName));
            }

            return companies.Single().ToEntityReference();
        }
开发者ID:hydr,项目名称:VcardCrmImporter,代码行数:28,代码来源:OrganizationServiceExtensions.cs

示例7: GetCompanyClassificationReferenceByName

        public static EntityReference GetCompanyClassificationReferenceByName(this IOrganizationService service, string companyClassification)
        {
            Guard.ArgumentNotNullOrEmpty(companyClassification, "companyClassification");

            if (companyClassification == "Uncategorized")
            {
                return null;
            }

            var productTypeNameCondition = ConditionExpressionHelper.CreateEqualsCondition("xv_name", companyClassification);
            var filter = new FilterExpression();
            filter.Conditions.Add(productTypeNameCondition);

            var query = new QueryExpression(xv_firmenklassifizierung.EntityLogicalName);
            query.Criteria.AddFilter(filter);

            var productTypeEntity = service.RetrieveMultiple(query)
                .Entities
                .FirstOrDefault();

            if (productTypeEntity == null)
            {
                throw new CrmEntityNotFoundException(string.Format("Company classification '{0}' was not found.", companyClassification));
            }

            return productTypeEntity.ToEntityReference();
        }
开发者ID:hydr,项目名称:VcardCrmImporter,代码行数:27,代码来源:OrganizationServiceExtensions.cs

示例8: Visit

 public override SqlFragment Visit(FilterExpression expression)
 {
     SelectStatement select = VisitInputExpressionEnsureSelect(expression.Input.Expression,
         expression.Input.VariableName, expression.Input.VariableType);
     select = WrapIfNotCompatible(select, expression.ExpressionKind);
     select.Where = expression.Predicate.Accept(this);
     return select;
 }
开发者ID:noahvans,项目名称:mariadb-connector-net,代码行数:8,代码来源:SelectGenerator.cs

示例9: GetUsers

        /// <summary>
        /// Obtains all users corresponding to the search filter
        /// </summary>
        /// <param name="value">Search filter</param>
        /// <returns>List of users matching the search filter</returns>
        public List<Entity> GetUsers(string value)
        {
            var users = new List<Entity>();

            var ceStatus = new ConditionExpression("isdisabled", ConditionOperator.Equal, false);

            var feStatus = new FilterExpression();
            feStatus.AddCondition(ceStatus);

            var qe = new QueryExpression("systemuser");
            qe.ColumnSet = new ColumnSet("systemuserid", "fullname", "lastname", "firstname", "domainname", "businessunitid");
            qe.AddOrder("lastname", OrderType.Ascending);
            qe.Criteria = new FilterExpression();
            qe.Criteria.Filters.Add(new FilterExpression());
            qe.Criteria.Filters[0].FilterOperator = LogicalOperator.And;
            qe.Criteria.Filters[0].Filters.Add(feStatus);
            qe.Criteria.Filters[0].Filters.Add(new FilterExpression());
            qe.Criteria.Filters[0].Filters[1].FilterOperator = LogicalOperator.Or;

            if (value.Length > 0)
            {
                bool isGuid = false;

                try
                {
                    Guid g = new Guid(value);
                    isGuid = true;
                }
                catch
                { }

                if (isGuid)
                {
                    var ce = new ConditionExpression("systemuserid", ConditionOperator.Equal, value);
                    qe.Criteria.Filters[0].Filters[1].AddCondition(ce);
                }
                else
                {
                    var ce = new ConditionExpression("fullname", ConditionOperator.Like, value.Replace("*", "%"));
                    var ce2 = new ConditionExpression("firstname", ConditionOperator.Like, value.Replace("*", "%"));
                    var ce3 = new ConditionExpression("lastname", ConditionOperator.Like, value.Replace("*", "%"));
                    var ce4 = new ConditionExpression("domainname", ConditionOperator.Like, value.Replace("*", "%"));

                    qe.Criteria.Filters[0].Filters[1].AddCondition(ce);
                    qe.Criteria.Filters[0].Filters[1].AddCondition(ce2);
                    qe.Criteria.Filters[0].Filters[1].AddCondition(ce3);
                    qe.Criteria.Filters[0].Filters[1].AddCondition(ce4);
                }
            }

            foreach (var record in service.RetrieveMultiple(qe).Entities)
            {
                users.Add(record);
            }

            return users;
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:62,代码来源:CrmAccess.cs

示例10: ResultExpressionTestHelper5

        public void ResultExpressionTestHelper5()
        {
            var target = new FilterExpression<Person>();

            var persons = _peoples.Where(target.Start(p => p is Int32).ResultExpression);
            var expected = _peoples.Where(p => p is Person);
            bool result = AreCollectionsEquals(persons.ToList(), expected.ToList());
            Assert.IsFalse(result);
        }
开发者ID:AlbertoMonteiro,项目名称:DynamicExpressionBuilder,代码行数:9,代码来源:FilterExpressionTest.cs

示例11: Filter

        public static ClarifyGeneric Filter(this ClarifyGeneric generic, Func<FilterExpression, Filter> filterFunction)
        {
            var filterExpression = new FilterExpression();

            var filter = filterFunction(filterExpression);

            generic.Filter.AddFilter(filter);

            return generic;
        }
开发者ID:DovetailSoftware,项目名称:dovetail-bootstrap,代码行数:10,代码来源:ClarifyGenericExtensions.cs

示例12: SQLEditorAndResults

        public SQLEditorAndResults(string filePath, string sql, bool temp)
        {
            InitializeComponent();

            btnSave.Text = "";

            imageListTabs.Images.Add("Results", FamFamFam.application_split);
            imageListTabs.Images.Add("Output", FamFamFam.application_xp_terminal);
            imageListTabs.Images.Add("SQLLog", FamFamFam.clock);
            imageListTabs.Images.Add("Info", FamFamFam.information);
            imageListTabs.Images.Add("TableData", FamFamFam.table);

            tpResults.ImageKey = "Results";
            tpOutput.ImageKey = "Output";
            tpSQLLog.ImageKey = "SQLLog";
            tpInfo.ImageKey = "Info";
            tpTableData.ImageKey = "TableData";

            this.filePath = temp ? "" : filePath;
            this.tempFilePath = temp ? filePath : "";

            if (!string.IsNullOrEmpty(filePath))
            {
                txtSQL.LoadFile(filePath);
                InitialText = txtSQL.Text;
            }
            else if (!string.IsNullOrEmpty(tempFilePath))
            {
                txtSQL.LoadFile(tempFilePath);
                InitialText = "this is not a saved file. just a temp file. this sentence is not for warning, just to be sure that InitialText is not equal to txtSQL.Text. (to keep the editor in Modified state)";
            }
            else if (!string.IsNullOrEmpty(sql))
            {
                txtSQL.Text = sql;
                InitialText = txtSQL.Text;
            }
            else
            {
                InitialText = txtSQL.Text = "";
            }

            txtSQLLog.Document.ReadOnly = true;

            gridShowTable.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(gridShowTable_ColumnHeaderMouseClick);
            gridShowTable.CellValueChanged += delegate { btnSave.Text = "Click to save!"; };
            gridShowTable.UserAddedRow += delegate { btnSave.Text = "Click to save!"; };
            btnNextPage.Click += new EventHandler(btnNextPage_Click);
            btnPrevPage.Click += new EventHandler(btnPrevPage_Click);
            btnSave.Click += new EventHandler(btnSave_Click);
            btnRefresh.Click += delegate { bindTableData(); };
            btnDeleteSelectedRows.Click += delegate { deleteSelectedRows(); };
            btnFilter.Click += new EventHandler(btnFilter_Click);

            fExp = new FilterExpression();
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:55,代码来源:SQLEditorAndResults.cs

示例13: ExecutePricingTypeUpdate

        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePricingTypeUpdate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            // TODO: Implement your custom Plug-in business logic.

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService service = localContext.OrganizationService;
            Guid quoteProductID = (Guid)((Entity)context.InputParameters["Target"]).Id;
            ColumnSet set = new ColumnSet();
            set.AllColumns = true;
            var quote = service.Retrieve("quote", quoteProductID, set);


            if (context.Depth > 1)
            {
                return;
            }
            else
            {

                //First I get the base values that I need for the calculations

                var pricingType = (OptionSetValue)quote["new_pricingtype"];

                ConditionExpression condition = new ConditionExpression();
                condition.AttributeName = "quoteid";
                condition.Operator = ConditionOperator.Equal;
                condition.Values.Add(quoteProductID);

                FilterExpression filter = new FilterExpression();
                filter.AddCondition(condition);

                QueryExpression query = new QueryExpression();
                query.EntityName = "quotedetail";
                query.ColumnSet = new ColumnSet(true);
                query.Criteria = filter;

                EntityCollection quotedetails = service.RetrieveMultiple(query);

                foreach (var detail in quotedetails.Entities)
                {
                    detail["new_pricingtype"] = new OptionSetValue(pricingType.Value);
                    service.Update(detail);
                }


                service.Update(quote);

            }
        }
开发者ID:borisov90,项目名称:Projects,代码行数:69,代码来源:PricingTypeUpdate.cs

示例14: ConditionHelper

        public FilterExpression ConditionHelper(LogicalOperator op, Dictionary<string, object> keyValues)
        {
            FilterExpression filter = new FilterExpression();
            filter.FilterOperator = op;

            foreach (KeyValuePair<string, object> item in keyValues)
            {
                filter.Conditions.Add(new ConditionExpression(item.Key, ConditionOperator.Equal, item.Value));
            }
            return filter;
        }
开发者ID:rexghadaffi,项目名称:TE-System,代码行数:11,代码来源:ContextHelpers.cs

示例15: ResultExpressionTestHelper2

        public void ResultExpressionTestHelper2()
        {
            var target = new FilterExpression<Person>();

            var filterExpression = target.Start(p => p.Name.Contains("berto")).And(p => p.Age <= 25);

            var persons = _peoples.Where(filterExpression.ResultExpression);
            var expected = _peoples.Where(p => p.Name.Contains("berto") && p.Age <= 25);
            bool result = AreCollectionsEquals(persons.ToList(), expected.ToList());
            Assert.IsTrue(result);
        }
开发者ID:AlbertoMonteiro,项目名称:DynamicExpressionBuilder,代码行数:11,代码来源:FilterExpressionTest.cs


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