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


C# Query.Where方法代码示例

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


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

示例1: Issue106_Guid_In_Query_Should_Retrieve_Matching_Records

        public void Issue106_Guid_In_Query_Should_Retrieve_Matching_Records()
        {
            var query = new Query<Product>(_provider);
            var firstSku= query.First().Sku;
            var result = query.Where(p => p.Sku == firstSku).ToList();

            Assert.Equal(firstSku, result[0].Sku);
        }
开发者ID:RyanDansie,项目名称:SubSonic-3.0,代码行数:8,代码来源:QueryTests.cs

示例2: GetRepresentanteComercial

        public static RepresentanteComercial GetRepresentanteComercial(string username)
        {
            Query supQuery = new Query();
            AttributeTest at = AttributeTest.Equal("usuario", username);
            supQuery.Where(at);

            return RepresentanteComercial.FindWithQuery(supQuery).FirstOrDefault();
        }
开发者ID:hihack,项目名称:CRM.Mobile,代码行数:8,代码来源:ModelHelper.cs

示例3: GetByAlias

 /// <summary>
 /// Gets an <see cref="IMacro"/> object by its alias
 /// </summary>
 /// <param name="alias">Alias to retrieve an <see cref="IMacro"/> for</param>
 /// <returns>An <see cref="IMacro"/> object</returns>
 public IMacro GetByAlias(string alias)
 {
     using (var repository = _repositoryFactory.CreateMacroRepository(_uowProvider.GetUnitOfWork()))
     {
         var q = new Query<IMacro>();
         q.Where(macro => macro.Alias == alias);
         return repository.GetByQuery(q).FirstOrDefault();
     }
 }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:14,代码来源:MacroService.cs

示例4: TestNewInstance

        public void TestNewInstance()
        {
            using (var database = new CouchDatabase("http://localhost:5984/"))
            {
                var mapping = new ImplicitMapping();
                var policy = new QueryPolicy();

                var provider = new CouchDbQueryProvider(new CouchDbConnection(database), mapping, policy);
                var query = new Query<Car>(provider);
                var queryable = query.Where(x => x.Make == "Audi" && x.HorsePowers == 123);
                var cars = queryable.ToList();
                foreach (var car in cars)
                {
                    car.Model = "Cool";
                }
            }
        }
开发者ID:bisand,项目名称:NetCouch,代码行数:17,代码来源:EntityProviderTests.cs

示例5: Simple_Query_Translate

        public void Simple_Query_Translate()
        {
            var container = new NinjectContainer();
            var map = container.Resolve<IMappingManager>();
            var mapper = new PersonMap();
            mapper.ExecuteMapping();
            map.Register(mapper.MappedType, mapper);

            var query = new Query<Person>();
            query.Where(x => x.Name).Equal("Alaor").And(x => x.Age).GreaterThan(18).And(x => x.Id).NotEqual(0);

            var translator = new QueryTranslator(map);
            var result = translator.Translate(query);

            result.SqlText.Trim().ToUpper().Should().Be("NAME = @PARAMETER_0 AND AGE > @PARAMETER_1 AND ID <> @PARAMETER_2");
            result.Parameters.Count.Should().Be(3);
        }
开发者ID:BrunoCaimar,项目名称:Drikka,代码行数:17,代码来源:QueryTranslatorTests.cs

示例6: GetCategoriasPregunta

        public static CategoriaPreguntaModelCollection GetCategoriasPregunta(int idFormulario)
        {
            //Consultas las categorias de preguntas filtradas por actividad
            Query supQuery = new Query();
            supQuery.Distinct = true;
            supQuery.Select("pr.idCategoriaPregunta");
            supQuery.From("Pregunta", "pr");
            supQuery.Join("PreguntaFormulario", "pf", "pf.idPregunta", "pr.idPregunta");
            supQuery.Where(new AttributeTest("pf.idFormulario", idFormulario, AttributeTest.EQUAL));

            /* ************* */
            Query filterQuery = new Query();
            AttributeTest test = new AttributeTest();
            test.Attribute = "idCategoriaPregunta";
            test.Value = supQuery;
            test.Operator = AttributeTest.IN;
            filterQuery.Where(test);

            return new CategoriaPreguntaModelCollection(CategoriaPregunta.FindWithQuery(filterQuery));
        }
开发者ID:hihack,项目名称:CRM.Mobile,代码行数:20,代码来源:FormularioCheckListBusiness.cs

示例7: GetPreguntas

        public static PreguntaFormularioModelCollection GetPreguntas(FormularioModel formulario)
        {
            //Query subSupQuery = new Query();
            //subSupQuery.Distinct = true;
            //subSupQuery.Select("pf.idPregunta");
            //subSupQuery.From("PreguntaFormulario", "pf");
            //subSupQuery.Where(new AttributeTest("pf.idFormulario", idFormulario, AttributeTest.EQUAL));

            //AttributeTest filterTest = new AttributeTest();
            //filterTest.Attribute = "idPregunta";
            //filterTest.Value = subSupQuery;
            //filterTest.Operator = AttributeTest.IN;

            //SortCriteria sort = new SortCriteria();
            //sort.Add("idPregunta", (int)SortOrderType.Ascending);

            //Query filterQuery = new Query();
            //filterQuery.Where(filterTest);
            //filterQuery.SortCriteria = sort;

            // Pregunta.FindWithQuery(filterQuery)

            AttributeTest filterTest = new AttributeTest();
            filterTest.Attribute = "idFormulario";
            filterTest.Value = formulario.IdFormulario;
            filterTest.Operator = AttributeTest.EQUAL;

            SortCriteria sort = new SortCriteria();
            sort.Add("idPregunta", (int)SortOrderType.Ascending);

            Query filterQuery = new Query();
            filterQuery.Where(filterTest);
            filterQuery.SortCriteria = sort;

            return new PreguntaFormularioModelCollection(PreguntaFormulario.FindWithQuery(filterQuery));
        }
开发者ID:hihack,项目名称:CRM.Mobile,代码行数:36,代码来源:FormularioCheckListBusiness.cs

示例8: TestMethod1

 public void TestMethod1()
 {
     var query = new Query<Person>();
     var a = query.Where(x => x.Name).Equal("Alaor").And(x => x.Age).GreaterThan(18).And(x => x.Id).NotEqual(0);
 }
开发者ID:BrunoCaimar,项目名称:Drikka,代码行数:5,代码来源:QueryExtensionMethodsTests.cs

示例9: FindMembersByEmail

        /// <summary>
        /// Does a search for members that contain the specified string in their email address
        /// </summary>
        /// <param name="emailStringToMatch"></param>
        /// <returns></returns>
        public IEnumerable<IMember> FindMembersByEmail(string emailStringToMatch)
        {
            var uow = _uowProvider.GetUnitOfWork();
            using (var repository = _repositoryFactory.CreateMemberRepository(uow))
            {
                var query = new Query<IMember>();


                query.Where(member => member.Email.Contains(emailStringToMatch));

                return repository.GetByQuery(query);
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:18,代码来源:MemberService.cs

示例10: PopulateParameters

        /// <summary>
        /// Populates MySqlCommand with parameters from CRUD Query object
        /// Note: this code was purposely made provider specific because other providers may treat some nuances differently
        /// </summary>
        public void PopulateParameters(MySqlCommand cmd, Query query)
        {
            foreach(var par in query.Where(p=> p.HasValue))
                cmd.Parameters.AddWithValue(par.Name, par.Value);

               if (query.StoreKey!=null)
               {
                var where = GeneratorUtils.KeyToWhere(query.StoreKey, cmd.Parameters);
                cmd.CommandText += "\n WHERE \n {0}".Args( where );
               }

               CRUDGenerator.ConvertParameters(m_Store, cmd.Parameters);
        }
开发者ID:itadapter,项目名称:nfx,代码行数:17,代码来源:MySQLCRUDScriptQueryHandler.cs

示例11: Main

 public void Main(string[] args)
 {
     var query = new Query<SimpleModel>(new DbQueryProvider());
     Console.WriteLine(query.Where(x => x.TestString == "Test"));
 }
开发者ID:neil-119,项目名称:CoreCLR-Queryable-Test,代码行数:5,代码来源:Program.cs

示例12: SelectTest_WithWhere

        public void SelectTest_WithWhere()
        {
            using (var qry = new Query<Customer>(GetConnectionString()))
            {
                var result = qry.Where(c => c.CustomerID == 1).SelectToSingle();
                var methodName = MethodBase.GetCurrentMethod().Name;
                var expectedQuery = GetQueryText(methodName);
                Assert.IsTrue(CompareText(expectedQuery, qry.QueryStatement.SqlQuery, methodName));
                Assert.IsTrue(result is Customer);
                Assert.AreEqual(1, result.CustomerID);
                Assert.AreEqual("Test Customer 1", result.Name);
                Assert.AreEqual("555-555-5555", result.Phone);
            }

            // c.CustomerID == 1
            // c.CustomerID != 1
            // c.CustomerID > 1
            // c.CustomerID < 1
            // c.CustomerID >= 1
            // c.CustomerID <= 1

            // TODO string where operators

            // contains
            // ==
            // !=
            // starts with
            // ends with
        }
开发者ID:smashdevcode,项目名称:simple-orm,代码行数:29,代码来源:QueryTests.cs

示例13: Issue106_Guid_Should_Be_Allowed_In_Query

 public void Issue106_Guid_Should_Be_Allowed_In_Query()
 {
     var query = new Query<Product>(_provider);
     var someGuid = Guid.NewGuid(); // Some guid - wedo not need to retrieve a value!
     Assert.DoesNotThrow(() => query.Where(p => p.Sku == someGuid));
 }
开发者ID:RyanDansie,项目名称:SubSonic-3.0,代码行数:6,代码来源:QueryTests.cs

示例14: Query_Tests

        public void Query_Tests()
        {
            var kernel = new NinjectContainer();
            var maps = kernel.Resolve<IMappingManager>();
            var types = kernel.Resolve<BasicTypesMap>();

            maps.LoadFromAssembly(typeof(PersonMap).Assembly);
            types.MapTypes();

            var executer = kernel.Resolve<GenericDomainsRepository<Person>>();

            var query = new Query<Person>();
            query.Where(x => x.Name).Equal("Alaor").And(x => x.Age).Equal(28).And(x => x.Id).GreaterThan(0);

            var result = executer.Query(query);

            Assert.IsNotNull(result);
            Assert.AreNotEqual(result.Count, 0);
        }
开发者ID:BrunoCaimar,项目名称:Drikka,代码行数:19,代码来源:GenericDomainsRepositoryTests.cs

示例15: GetFormularioXSeleccion

        public static FormularioModel GetFormularioXSeleccion(MotivoModel motivo, NegocioModel negocio)
        {
            Query supQuery = new Query();

            CompositeTest where = new CompositeTest();
            where.SetOperator(CompositeTest.AND);
            where.Add(new AttributeTest("idMotivo", motivo.IdMotivo, AttributeTest.EQUAL));
            where.Add(new AttributeTest("idNegocio", negocio.IdNegocio, AttributeTest.EQUAL));

            supQuery.Where(where);

            GenericList<SeleccionFormulario> seleccionFormulario = SeleccionFormulario.FindWithQuery(supQuery);
            if (seleccionFormulario.Size() > 0)
                return FormularioModel.Create(seleccionFormulario[0].Formulario);
            else
                return null;
        }
开发者ID:hihack,项目名称:CRM.Mobile,代码行数:17,代码来源:InteraccionBusiness.cs


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