Esempio n. 1
0
 public static ISingle <R> Zip <T1, T2, T3, T4, R>(
     ISingle <T1> s1, ISingle <T2> s2,
     ISingle <T3> s3, ISingle <T4> s4,
     Func <T1, T2, T3, T4, R> zipper)
 {
     return(Zip(
                new ISingle <object>[] {
         (ISingle <object>)s1, (ISingle <object>)s2,
         (ISingle <object>)s3, (ISingle <object>)s4,
     },
                LambdaHelper.ToFuncN(zipper)));
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var result = LambdaHelper.ModifyName("SMEE", name =>
            {
                string newName = string.Empty;
                newName        = "上微";
                return(newName);
            });

            Console.WriteLine(result);
            Console.Read();
        }
Esempio n. 3
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <APIGatewayProxyResponse> LambdaFunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
        {
            Debug.Untested();
            Debug.AssertValid(request);
            Debug.AssertValid(context);

            return(await LambdaHelper.ExecuteGetAsync(request, async (IDataStores dataStores) => {
                Debug.AssertValid(dataStores);

                return await GetCountries(dataStores, request);
            }));
        }
Esempio n. 4
0
        private SA_Lambda GetLambdaFunctionFromZipFileName(string fileName, out bool exist)
        {
            LambdaHelper helper = new LambdaHelper(
                GlobalVariables.Enviroment,
                GlobalVariables.Region,
                GlobalVariables.Color);
            var functionName = FormatLambdaFunctionname(fileName);
            var lambda       = lambdaHelper.GetFromFunctionName(functionName);

            exist = (lambda != null);
            return(lambda);
        }
Esempio n. 5
0
        public List <T> Filter <T, TResult>(Expression <Func <T, bool> > predicate, Expression <Func <T, TResult> > orderBy, out int total, int index = 0, int size = 50, bool isAsc = true) where T : class
        {
            string sql = new SQLQuery().Select(String.Join(",", typeof(T).GetEntityColumnNames()))
                         .From($"{this.mDatabaseName}{typeof(T).GetEntityTableName()}")
                         .Where(String.Join(" ", typeof(T).GetEntityColumnNames(LambdaHelper.GetConditions(predicate))))
                         .OrderBy(typeof(T).GetEntityColumnName(LambdaHelper.GetColumn(orderBy).FirstOrDefault(), true))
                         .Skip((index - 1) * size)
                         .Take(size)
                         .Qenerate();

            total = 500;
            return(this.DBContext.SqlReader(sql).ToList <T>());
        }
Esempio n. 6
0
        private static Expression <Func <LogEntry, bool> > And(this Expression <Func <LogEntry, bool> > lhs, Expression <Func <LogEntry, bool> > rhs)
        {
            if (rhs is null)
            {
                return(lhs);
            }

            var logEntryParameter = Expression.Parameter(typeof(LogEntry), "logEntry");

            var body = Expression.And(LambdaHelper.RebindBody(lhs, logEntryParameter), LambdaHelper.RebindBody(rhs, logEntryParameter));

            return(Expression.Lambda <Func <LogEntry, bool> >(body, logEntryParameter));
        }
Esempio n. 7
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <APIGatewayProxyResponse> handleRequest(APIGatewayProxyRequest request, ILambdaContext context)
        {
            Debug.Untested();
            Debug.AssertValid(request);
            Debug.AssertValid(request.Headers);
            Debug.AssertValid(context);

            return(await LambdaHelper.ExecuteGetAsync(request, async (IDataStores dataStores) => {
                Debug.AssertValid(dataStores);

                return await GetUserDetails(dataStores, request.Headers);
            }));
        }
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <APIGatewayProxyResponse> LambdaFunctionHandler(APIGatewayProxyRequest request, ILambdaContext context)
        {
            Debug.Untested();
            Debug.AssertValid(request);
            Debug.AssertValid(context);

            return(await LambdaHelper.ExecuteAsync(request, APIHelper.REQUEST_METHOD_POST, async (IDataStores dataStores, JObject requestBody) => {
                Debug.AssertValid(dataStores);
                Debug.AssertValid(requestBody);

                return await CreateAccount(dataStores, requestBody);
            }));
        }
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <APIGatewayProxyResponse> handleRequest(APIGatewayProxyRequest request, ILambdaContext context)
        {
            Debug.Untested();
            Debug.AssertValid(request);
            Debug.AssertValid(context);

            return(await LambdaHelper.ExecuteAsync(request, APIHelper.REQUEST_METHOD_PUT, async (IDataStores dataStores, JObject requestBody) => {
                Debug.AssertValid(dataStores);
                Debug.AssertValid(requestBody);

                return await ResendEmailVerification(dataStores, requestBody);
            }));
        }
Esempio n. 10
0
        protected IQueryable <TEntity> FindAll(Expression <Func <TEntity, bool> > pression)
        {
            var property = typeof(TEntity).GetProperty(CLIENT_ID);

            IQueryable <TEntity> query = _repository.FindAll(pression);

            if (property != null && AllowedGrant == OAuthGrant.Client)
            {
                query = query.Where(LambdaHelper.BuildQuery <TEntity>("ClientId == " + ClientId));
            }

            return(query);
        }
Esempio n. 11
0
        public List <T1> CrossJoin <T1, T2, TCross, TResult>(Expression <Func <T1, TCross> > crossApply, Expression <Func <T1, bool> > predicate, Expression <Func <T1, TResult> > orderBy, out int total, int index = 0, int size = 50, bool isAsc = true) where T1 : class
        {
            string sql = new SQLQuery().Select(String.Join(",", typeof(T1).GetEntityColumnNames()))
                         .From($"{this.mDatabaseName}{typeof(T1).GetEntityTableName()}")
                         .Cross($"{typeof(T2).GetEntityTableName()}({String.Join(",", typeof(T1).GetEntityColumnNames(LambdaHelper.GetColumn(crossApply)))})")
                         .Where(String.Join(" ", typeof(T1).GetEntityColumnNames(LambdaHelper.GetConditions(predicate))))
                         .OrderBy(typeof(T1).GetEntityColumnName(LambdaHelper.GetColumn(orderBy).FirstOrDefault(), true))
                         .Skip((index - 1) * size)
                         .Take(size)
                         .Qenerate();

            total = this.Count <T1>(predicate);
            return(this.DBContext.SqlReader(sql).ToList <T1>());
        }
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <APIGatewayProxyResponse> handleRequest(APIGatewayProxyRequest request, ILambdaContext context)
        {
            Debug.Untested();
            Debug.AssertValid(request);
            Debug.AssertValid(request.Headers);
            Debug.AssertValid(context);

            return(await LambdaHelper.ExecuteAsync(request, APIHelper.REQUEST_METHOD_PUT, async (IDataStores dataStores, JObject requestBody) => {
                Debug.AssertValid(dataStores);
                Debug.AssertValid(requestBody);

                return await SetUserAllowNonEssentialEmails(dataStores, request.Headers, requestBody);
            }));
        }
Esempio n. 13
0
        public bool Validate(CustomValidationService service)
        {
            ValidationErrors = new SerializableDictionary <string, string>();

            if (string.IsNullOrWhiteSpace(ExternalServiceId))
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.ExternalServiceId), "Service.ExternalServiceId is a mandatory field.");
            }

            if (Priority == null || Priority < 1)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.Priority), "Service.Priority is a mandatory field.");
            }

            if (ProvisionSequence == null || ProvisionSequence < 1)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.ProvisionSequence), "Service.ProvisionSequence is a mandatory field and must be greater then 0.");
            }

            if (ProvisionDate == null || ProvisionDate == DateTime.MinValue)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.ProvisionDate), "Service.ProvisionDate is a mandatory field.");
            }

            //Note: Validation the child class as well.

            if (Locations == null)
            {
                ValidationErrors.Add(LambdaHelper <Service> .GetPropertyName(x => x.Locations), "Service.Locations is a mandatory field.");
            }
            else
            {
                foreach (var location in Locations)
                {
                    if (location.Validate(service))
                    {
                        foreach (var validationError in location.ValidationErrors)
                        {
                            if (!ValidationErrors.ContainsKey(validationError.Key))
                            {
                                ValidationErrors.Add(validationError.Key, validationError.Value);
                            }
                        }
                    }
                }
            }

            return(ValidationErrors.Count > 0);
        }
Esempio n. 14
0
        private static IOrderedQueryable <T> OrderingHelper <T>(IQueryable <T> source, string propertyName, bool descending, bool anotherLevel)
        {
            var param    = Expression.Parameter(typeof(T));
            var property = Expression.Property(param, propertyName);
            var sort     = LambdaHelper <T> .GetPropertyLambdaExp(propertyName);

            var call = Expression.Call(typeof(Queryable),
                                       (!anotherLevel ? "OrderBy" : "ThenBy") + (descending ? "Descending" : string.Empty),
                                       new[] { typeof(T), property.Type },
                                       source.Expression,
                                       Expression.Quote(sort));
            var query = (IOrderedQueryable <T>)source.Provider.CreateQuery <T>(call);

            return(query);
        }
Esempio n. 15
0
        /// <summary>
        /// 获取筛选 Queryable
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public virtual IQueryable <TEntity> QueryableFilterEntities(Dictionary <string, string> filter = null, bool isDelete = false)
        {
            var query = Entities(isDelete);

            if (filter != null)
            {
                var tmpExpression = LambdaHelper.True <TEntity>();
                foreach (var keyValue in filter)
                {
                    tmpExpression = tmpExpression.And <TEntity>(LambdaHelper.GetContains <TEntity>(keyValue.Key, keyValue.Value));
                }
                query = query.Where(tmpExpression);
            }
            return(query);
        }
Esempio n. 16
0
        public void TestGetValue_Method()
        {
            //1级返回值
            Expression <Func <LambdaModelTest, bool> > expression = t => t.Name.Contains("A");

            Assert.AreEqual("A", LambdaHelper.GetValue(expression));

            //二级返回值
            expression = t => t.A.Address.Contains("B");
            Assert.AreEqual("B", LambdaHelper.GetValue(expression));

            //三级返回值
            expression = t => t.A.B.Name.StartsWith("C");
            Assert.AreEqual("C", LambdaHelper.GetValue(expression));
        }
Esempio n. 17
0
        public SerializableDictionary <string, string> Validate(tUserData userData)
        {
            var validationErrors = new SerializableDictionary <string, string>();

            if (userData == null)
            {
                validationErrors.Add(LambdaHelper <tUserData> .GetPropertyName(x => x), "UserData is a mandatory field.");
            }
            else
            {
                if (userData.ShData == null)
                {
                    validationErrors.Add(LambdaHelper <tShData> .GetPropertyName(x => x), "ShData is a mandatory field.");
                }
                else
                {
                    if (userData.ShData.RepositoryData == null)
                    {
                        validationErrors.Add(LambdaHelper <tTransparentData> .GetPropertyName(x => x), "RepositoryData is a mandatory field.");
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(userData.ShData.RepositoryData.ServiceIndication))
                        {
                            validationErrors.Add("ServiceIndication", "ServiceIndication is a mandatory field.");
                        }

                        if (userData.ShData.RepositoryData.ServiceData == null)
                        {
                            ItemChoiceType gggg = userData.ShData.RepositoryData.ServiceData.Item.ItemElementName;
                            validationErrors.Add(LambdaHelper <tServiceData> .GetPropertyName(x => x), "ServiceData is a mandatory field.");
                        }
                        else
                        {
                            if (userData.ShData.RepositoryData.ServiceData.Item == null)
                            {
                                validationErrors.Add(LambdaHelper <tMetaSwitchData> .GetPropertyName(x => x), "MetaSwitchData is a mandatory field.");
                            }
                            else
                            {
                            }
                        }
                    }
                }
            }

            return(validationErrors);
        }
Esempio n. 18
0
        public virtual IQueryable <TEntity> Join(IQueryable <TEntity> query, List <Expression <Func <TEntity, object> > > associations)
        {
            associations = associations != null && associations.Count() > 0 ?
                           associations : LambdaHelper <TEntity> .ToFuncProperty(Profile.Associations.ToArray());

            if (query != null && associations != null)
            {
                foreach (Expression <Func <TEntity, object> > association in associations)
                {
                    query = query.Include(association);
                    //query = query.Include(association).AsNoTracking();
                }
            }

            return(query);
        }
Esempio n. 19
0
 public static ISingle <R> Zip <T1, T2, T3, T4, T5, T6, T7, T8, R>(
     ISingle <T1> s1, ISingle <T2> s2,
     ISingle <T3> s3, ISingle <T4> s4,
     ISingle <T5> s5, ISingle <T6> s6,
     ISingle <T7> s7, ISingle <T8> s8,
     Func <T1, T2, T3, T4, T5, T6, T7, T8, R> zipper)
 {
     return(Zip(
                new ISingle <object>[] {
         (ISingle <object>)s1, (ISingle <object>)s2,
         (ISingle <object>)s3, (ISingle <object>)s4,
         (ISingle <object>)s5, (ISingle <object>)s6,
         (ISingle <object>)s7, (ISingle <object>)s8
     },
                LambdaHelper.ToFuncN(zipper)));
 }
Esempio n. 20
0
        public PagedResultDto <ReagentInfoDto> GetReagentInfosPage(GetReagentInfosInput input)
        {
            //帅选
            var where = LambdaHelper.True <TB_ReagentInfo>();
            if (input.Filters != null && input.Filters.Count > 0)
            {
                foreach (var item in input.Filters)
                {
                    if (item.ColumName == "ReagentName")
                    {
                        item.ColumValue = item.ColumValue.ToUpper();
                    }
                    where = where.And(LambdaHelper.GetContains <TB_ReagentInfo>(item.ColumName, item.ColumValue));
                }
            }
            var query = repository.GetAll().Where(where);

            //排序
            if (!string.IsNullOrEmpty(input.Sorting))
            {
                if (input.Sorting.Contains("-"))
                {
                    var sort = input.Sorting.Split("-");
                    query = sort[1] == "desc" ? query.OrderByDescending(sort[0]) : query.OrderBy(sort[0]);
                }
                else
                {
                    query = query.OrderBy(input.Sorting);
                }
            }
            else
            {
                query = query.OrderBy(t => t.ID);
            }
            //query = !string.IsNullOrEmpty(input.Sorting) ? query.OrderBy(input.Sorting) : query.OrderBy(t => t.ID);
            //获取总数
            var totalCount = query.Include(a => a.ID).Count();
            //默认的分页方式
            //var reagentList = query.Skip(input.SkipCount).Take(input.MaxResultCount).ToList();

            //ABP提供了扩展方法PageBy分页方式
            var reagentList = query.PageBy(input).ToList();
            var result      = new PagedResultDto <ReagentInfoDto>(totalCount, ObjectMapper.Map <List <ReagentInfoDto> >(reagentList));

            return(result);
        }
Esempio n. 21
0
        public virtual IQueryable <TEntity> Join(IQueryable <TEntity> query, List <Expression <Func <TEntity, object> > > associations)
        {
            associations = associations != null && associations.Count() > 0 ?
                           associations : LambdaHelper <TEntity> .ToFuncProperty(Profile.Associations.ToArray());

            if (query != null && associations != null)
            {
                associations.ForEach(x => { query = query.Fetch(x); });

                //foreach (Expression<Func<TEntity, object>> association in associations)
                //{
                //    query = query.Fetch(association);
                //}
            }

            return(query);
        }
Esempio n. 22
0
        /// <summary>
        /// 首次加载、列表操作、翻页、排序、刷新、搜索查询、Ajax请求树
        /// </summary>
        /// <param name="pagingModel"></param>
        /// <returns></returns>
        public override ActionResult Index([ModelBinder(typeof(PagingModelBinder))] PagingModel pagingModel)
        {
            CategoriesViewModel cvm = new CategoriesViewModel();

            ViewBag.Sort = pagingModel.SortOptions;
            var parentId   = Request.Params["parentId"];
            var parentCode = Request.Params["parentCode"];

            if (String.IsNullOrWhiteSpace(parentId))
            {
                cvm.CategoriesTree = model.GetList(p => p.ParentId == null);
            }
            else
            {
                Int32 pId = Int32.Parse(parentId);
                cvm.CategoriesTree = model.GetList(p => p.ParentId == pId);
            }

            var expr = LambdaHelper.BuildLambdasOr <Category>(pagingModel.QueryFields, QueryMethods.Contains, pagingModel.Query);

            if (String.IsNullOrWhiteSpace(parentCode))
            {
                cvm.CategoriesList = model.GetPagedList(pagingModel, expr);
            }
            else
            {
                var predicate = PredicateBuilder.True <Category>();
                predicate          = predicate.And(f => f.Code.StartsWith(parentCode)).And(expr);
                cvm.CategoriesList = model.GetPagedList(pagingModel, predicate);
            }

            if (Request.IsAjaxRequest())
            {
                if (Request.HttpMethod == "GET")
                {
                    return(PartialView("_Index", cvm));
                }
                else
                {
                    return(Json(new SuccessActionResult("Ok", cvm.CategoriesTree)));
                }
            }

            return(View("Index", cvm));
        }
Esempio n. 23
0
        private static Expression <Func <LogEntry, bool> > And(this Expression <Func <Exception, bool> > lhs, Expression <Func <LogEntry, bool> > rhs)
        {
            var logEntryParameter = Expression.Parameter(typeof(LogEntry), "logEntry");
            var logEntryException = Expression.Property(logEntryParameter, nameof(LogEntry.Exception));

            Expression body;

            if (rhs is null)
            {
                body = LambdaHelper.RebindBody(lhs, logEntryException);
            }
            else
            {
                body = Expression.And(LambdaHelper.RebindBody(lhs, logEntryException), LambdaHelper.RebindBody(rhs, logEntryParameter));
            }

            return(Expression.Lambda <Func <LogEntry, bool> >(body, logEntryParameter));
        }
Esempio n. 24
0
        public override ActionResult Query([ModelBinder(typeof(PagingModelBinder))] PagingModel pagingModel)
        {
            Response.Cache.SetOmitVaryStar(true);
            SelectProductsViewModel pvm = new SelectProductsViewModel();
            Category categoryModel      = new Category();

            ViewBag.Sort         = pagingModel.SortOptions;
            ViewBag.Query        = pagingModel.Query;
            pagingModel.PageSize = 10;

            var parentId   = Request.Params["parentId"];
            var parentCode = Request.Params["parentCode"];

            if (String.IsNullOrWhiteSpace(parentId))
            {
                pvm.CategoriesTree = categoryModel.GetList(p => p.ParentId == null);
            }
            else
            {
                Int32 pId = Int32.Parse(parentId);
                pvm.CategoriesTree = categoryModel.GetList(p => p.ParentId == pId);
            }

            var expr = LambdaHelper.BuildLambdasOr <Product>(pagingModel.QueryFields, QueryMethods.Contains, pagingModel.Query);

            if (String.IsNullOrWhiteSpace(parentCode))
            {
                pvm.ProductsList = model.GetPagedList(pagingModel, expr);
            }
            else
            {
                var predicate = PredicateBuilder.True <Product>();
                predicate        = predicate.And(f => f.Category.Code.StartsWith(parentCode)).And(expr);
                pvm.ProductsList = model.GetPagedList(pagingModel, predicate);
            }

            if (Request.HttpMethod == "GET")
            {
                return(PartialView("_Query", pvm));
            }

            //默认是PUT
            return(PartialView("Query", pvm));
        }
Esempio n. 25
0
        //public void DeleteSubscriber(string dn)
        //{
        //    //When using Sh-Update to delete an object, you must specify a sequence number but it can be any
        //    //arbitrary non-zero value.
        //    //The only element that can be present in the <MetaSwitchData> or <MetaSphereData> element is
        //    //the service indication with Action="delete". Any other elements will cause an error.

        //    var userData = new MetaSphere.tUserData
        //    {
        //        ShData = new[]
        //        {
        //            new tTransparentData
        //            {
        //                ServiceIndication = "Msph_Subscriber_BaseInformation",
        //                SequenceNumber = 1, //0 indicates a new subscriber so setting to 1 to avoid confusion. When deleting any sequence number outside of 0 can be used.
        //                ServiceData = new tServiceData
        //                {
        //                    Item = new tMetaSphereData
        //                    {
        //                        ItemElementName = MetaSphere.ItemChoiceType1.Msph_Subscriber_BaseInformation,
        //                        Item = new tMsph_Subscriber_BaseInformation
        //                        {
        //                            PrimaryPhoneNumber = dn,
        //                            Action = "delete",

        //                        }
        //                    }
        //                }

        //            }
        //        }
        //    };

        //    // Send it in as an Sh-Update request, and make sure it succeeded.
        //    MetaSphere.tExtendedResult extendedResult;
        //    ShUpdate(dn, userData, out extendedResult);
        //}

        public SerializableDictionary <string, string> Validate(tUserData userData)
        {
            //update.UserData.ShData[0].ServiceData.Item.Item
            var validationErrors = new SerializableDictionary <string, string>();

            if (userData == null)
            {
                validationErrors.Add(LambdaHelper <tUserData> .GetPropertyName(x => x), "UserData is a mandatory field.");
            }
            else
            {
                if (userData.ShData == null)
                {
                    validationErrors.Add(LambdaHelper <tTransparentData> .GetPropertyName(x => x),
                                         "TransparentData is a mandatory field.");
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(userData.ShData[0].ServiceIndication))
                    {
                        validationErrors.Add("ServiceIndication", "ServiceIndication is a mandatory field.");
                    }

                    if (userData.ShData[0].ServiceData == null)
                    {
                        validationErrors.Add(LambdaHelper <tServiceData> .GetPropertyName(x => x),
                                             "ServiceData is a mandatory field.");
                    }
                    else
                    {
                        if (userData.ShData[0].ServiceData.Item == null)
                        {
                            validationErrors.Add(LambdaHelper <tMetaSphereData> .GetPropertyName(x => x),
                                                 "MetaSphereData is a mandatory field.");
                        }
                        else
                        {
                        }
                    }
                }
            }

            return(validationErrors);
        }
Esempio n. 26
0
        /// <summary>
        /// 验证谓词,无效时返回null
        /// </summary>
        /// <typeparam name="T">实体类型</typeparam>
        /// <param name="predicate">谓词</param>
        /// <returns></returns>
        public static Expression <Func <T, bool> > ValidatePredicate <T>(Expression <Func <T, bool> > predicate)
        {
            predicate.CheckNull("predicate");
            if (LambdaHelper.GetCriteriaCount(predicate) > 1)
            {
                throw new InvalidOperationException(string.Format("仅允许添加一个条件,条件:{0}", predicate));
            }
            if (predicate.Value() == null)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(predicate.Value().ToString()))
            {
                return(null);
            }

            return(predicate);
        }
        public ValidatorItem(Expression <Func <T, object> > memberLambda, FrameworkElement control)
        {
            _kind = ValidatorItemKind.ViewModelProperty;

            _memberLambda  = memberLambda;
            _property_name = LambdaHelper.GetMemberName(memberLambda.Body);

            if (control is FormField)
            {
                _control   = null;
                _formfield = (FormField)control;
            }
            else
            {
                // FindParent returns null if not found.
                _control   = control;
                _formfield = VenturaVisualTreeHelper.FindParent <FormField>(control);
            }
        }
        public async Task <List <GeneInfoDto> > GetGeneInfosFilter(List <FilterInputDto> input)
        {
            //帅选
            var where = LambdaHelper.True <TB_GeneInfo>();
            if (input != null && input.Count > 0)
            {
                foreach (var item in input)
                {
                    if (item.ColumName == "GeneName")
                    {
                        item.ColumValue = item.ColumValue.ToUpper();
                    }
                    where = where.And(LambdaHelper.CreateEqual <TB_GeneInfo>(item.ColumName, item.ColumValue));
                }
            }
            var geneInfos = await repository.GetAllListAsync(where);

            return(ObjectMapper.Map <List <GeneInfoDto> >(geneInfos));
        }
Esempio n. 29
0
        public void TestGetValue_Boolean()
        {
            //空值返回null
            Assert.AreEqual(null, LambdaHelper.GetValue(null));

            //一级返回值
            Expression <Func <LambdaModelTest, bool> > expression = test => test.Name == "A";

            Assert.AreEqual("A", LambdaHelper.GetValue(expression));

            //二级返回值
            Expression <Func <LambdaModelTest, bool> > expression2 = test => test.A.Integer == 1;

            Assert.AreEqual(1, LambdaHelper.GetValue(expression2));

            //三级返回值
            Expression <Func <LambdaModelTest, bool> > expression3 = test => test.A.B.Name == "B";

            Assert.AreEqual("B", LambdaHelper.GetValue(expression3));
        }
Esempio n. 30
0
        public void TestGetParameter()
        {
            //空值返回null
            Assert.AreEqual(null, LambdaHelper.GetParameter(null));

            //一级返回值
            Expression <Func <LambdaTest1, object> > expression = test => test.Name == "A";

            Assert.AreEqual("test", LambdaHelper.GetParameter(expression).ToString());

            //二级返回值
            Expression <Func <LambdaTest1, object> > expression2 = test => test.A.Integer == 1;

            Assert.AreEqual("test", LambdaHelper.GetParameter(expression2).ToString());

            //三级返回值
            Expression <Func <LambdaTest1, object> > expression3 = test => test.A.B.Name == "B";

            Assert.AreEqual("test", LambdaHelper.GetParameter(expression3).ToString());
        }