/// <summary> /// Creates <see cref="OrCondition"/> between left and right <see cref="BaseCondition"/>s. /// </summary> /// <param name="leftCondition">left condition.</param> /// <param name="rightCondition">right condition.</param> public OrCondition(BaseCondition leftCondition, BaseCondition rightCondition) : base(leftCondition, rightCondition) { }
private string MakeSingleCondition(BaseCondition condItem) { string body = String.Empty; if (condItem is Condition) { var condition = (Condition) condItem; ObjectParameter param; body = MakeComarisonExpression(condition, out param); _objectParameters.Add(param); } else if (condItem is BiCondition || condItem.GetType().IsSubclassOf(typeof (BiCondition))) { var biCond = (BiCondition) condItem; string leftExpr = null; string rightExpr = null; if (biCond.LeftCondition == null && biCond.RightCondition == null) { return null; } if (biCond.LeftCondition != null) { if (biCond.LeftCondition is Condition) { ObjectParameter param; leftExpr = MakeComarisonExpression((Condition) biCond.LeftCondition, out param); _objectParameters.Add(param); } else { leftExpr = MakeSingleCondition(biCond.LeftCondition); } } if (biCond.RightCondition != null) { if (biCond.RightCondition is Condition) { ObjectParameter param; rightExpr = MakeComarisonExpression((Condition) biCond.RightCondition, out param); _objectParameters.Add(param); } else { rightExpr = MakeSingleCondition(biCond.RightCondition); } } if (leftExpr == null && rightExpr == null) { return null; } if (leftExpr == null) { body = rightExpr; } else if (rightExpr == null) { body = leftExpr; } else { if (biCond is OrCondition) { body = String.Format("({0}{1}{2})", leftExpr, PredicateConstants.OR, rightExpr); } else if (biCond is AndCondition) { body = String.Format("({0}{1}{2})", leftExpr, PredicateConstants.AND, rightExpr); } } } return body; }
private Expression MakeConditionExpression( BaseCondition baseCondition, ParameterExpression parameter, ref Expression sourceExpression) { Expression body = null; ParameterExpression pe; if (baseCondition is Condition) { Condition condition = (Condition) baseCondition; Type sourceType = ExpressionHelper.GetGenericType(sourceExpression); pe = condition.ElementType == null ? ExpressionHelper.CreateOrGetParameterExpression(sourceType, sourceType.Name, Factory.Store) : ExpressionHelper.CreateOrGetParameterExpression(condition.ElementType, condition.ElementType.Name, Factory.Store); body = MakeSimpleCondition(condition, pe, ref sourceExpression); } else if (baseCondition is BoolCondition) { body = Expression.Constant(((BoolCondition) baseCondition).Value); } else if (baseCondition is FieldCondition) { var fieldCondition = (FieldCondition) baseCondition; body = MakeSimpleCondition(fieldCondition); } else if (baseCondition is BiCondition || baseCondition.GetType().IsSubclassOf(typeof (BiCondition))) { var biCondition = (BiCondition) baseCondition; Expression leftExpression = null; Expression rightExpression = null; if (biCondition.LeftCondition == null && biCondition.RightCondition == null) { return null; } if (biCondition.LeftCondition != null) { if (!(biCondition.LeftCondition is Condition) || ((Condition) biCondition.LeftCondition).ElementType == null) { pe = parameter; } else { var leftCondition = ((Condition)biCondition.LeftCondition); pe = ExpressionHelper.CreateOrGetParameterExpression(leftCondition.ElementType, leftCondition.ElementType.Name, Factory.Store); } if (biCondition.LeftCondition is Condition) { leftExpression = MakeSimpleCondition((Condition) biCondition.LeftCondition, pe, ref sourceExpression); } else { leftExpression = MakeConditionExpression(biCondition.LeftCondition, pe, ref sourceExpression); } } if (biCondition.RightCondition != null) { if (!(biCondition.RightCondition is Condition) || ((Condition)biCondition.RightCondition).ElementType == null) { pe = parameter; } else { var rightCondition = ((Condition)biCondition.RightCondition); pe = ExpressionHelper.CreateOrGetParameterExpression(rightCondition.ElementType, rightCondition.ElementType.Name, Factory.Store); } if (biCondition.RightCondition is Condition) { rightExpression = MakeSimpleCondition((Condition) biCondition.RightCondition, pe, ref sourceExpression); } else { rightExpression = MakeConditionExpression(biCondition.RightCondition, pe, ref sourceExpression); } } if (leftExpression == null && rightExpression == null) { return null; } if (leftExpression == null) { body = rightExpression; } else if (rightExpression == null) { body = leftExpression; } else { if (biCondition is OrCondition) { body = Expression.Or(leftExpression, rightExpression); } else if (biCondition is AndCondition) { body = Expression.And(leftExpression, rightExpression); } } } else if (baseCondition is PredicateAggregationCondition) { PredicateAggregationCondition predicateAggregationCondition = (PredicateAggregationCondition) baseCondition; Type sourceType = ExpressionHelper.GetGenericType(sourceExpression); if (predicateAggregationCondition.ElementType != null && predicateAggregationCondition.ElementType != sourceType) { throw new SpoltyException( String.Format("Aggregation condition with ElementType {0} can not assign to queryable ElementType {1}", predicateAggregationCondition.ElementType, sourceType)); } var memberExpression = ExpressionHelper.CreateMemberExpression(sourceType, predicateAggregationCondition.EnumerableFieldName, parameter, ExpressionHelper.IEnumerableType); Expression conditionExpression = null; if (predicateAggregationCondition.Conditions.Count > 0) { Type memberType = ExpressionHelper.GetGenericType(memberExpression); predicateAggregationCondition.Conditions.SetElementType(memberType); conditionExpression = MakeConditionExpression(new AndCondition(predicateAggregationCondition.Conditions), parameter, ref memberExpression); conditionExpression = Expression.Lambda(conditionExpression, ExpressionHelper.CreateOrGetParameterExpression(memberType, memberType.Name, Factory.Store)); } switch (predicateAggregationCondition.AggregationMethod) { case AggregationMethod.All: body = Factory.CreateSimpleExpressionMaker().MakeAll(memberExpression, conditionExpression); break; case AggregationMethod.Any: body = Factory.CreateSimpleExpressionMaker().MakeAny(memberExpression, conditionExpression); break; case AggregationMethod.Average: break; case AggregationMethod.Count: body = Factory.CreateSimpleExpressionMaker().MakeCount(memberExpression, conditionExpression); break; case AggregationMethod.Max: break; case AggregationMethod.Min: break; case AggregationMethod.Sum: break; default: throw new SpoltyException("Not supported AggregationMethod."); } body = MakeComparisonExpression(body, Expression.Constant(predicateAggregationCondition.Value), predicateAggregationCondition.Operator); } return body; }
public IActionResult GetListFilesByProfileId([FromBody] BaseCondition <Profiles> condition) { var result = profileBUS.GetListFilesByProfileId(condition); return(Ok(result)); }
public IActionResult GetDocumentsByProfileId(BaseCondition <Profiles> condition) { return(Ok(profileBUS.GetDocumentsByProfileId(condition))); }
public IActionResult GetPagingWithSearchResults(BaseCondition <Profiles> condition) { var result = profileBUS.GetPagingWithSearchResults(condition); return(Ok(result)); }
public IActionResult ProfilesGetSearchWithPaging(BaseCondition <Profiles> condition) { return(Ok(profileBUS.ProfilesGetSearchWithPaging(condition))); }
public ReturnResult <Log> GetPagingWithSearchResults(BaseCondition <Log> condition) { var result = logDAL.GetPagingWithSearchResults(condition); return(result); }
public async Task <ReturnResult <TableOfContents> > GetPagingWithSearchResults(BaseCondition <TableOfContents> condition) { DbProvider provider = new DbProvider(); List <TableOfContents> list = new List <TableOfContents>(); string outCode = String.Empty; string outMessage = String.Empty; string totalRecords = String.Empty; var result = new ReturnResult <TableOfContents>(); try { provider.SetQuery("TableOfContents_GET_PAGING", System.Data.CommandType.StoredProcedure) .SetParameter("InWhere", System.Data.SqlDbType.NVarChar, condition.IN_WHERE ?? String.Empty) .SetParameter("InSort", System.Data.SqlDbType.NVarChar, condition.IN_SORT ?? String.Empty) .SetParameter("StartRow", System.Data.SqlDbType.Int, condition.PageIndex) .SetParameter("PageSize", System.Data.SqlDbType.Int, condition.PageSize) .SetParameter("TotalRecords", System.Data.SqlDbType.Int, DBNull.Value, System.Data.ParameterDirection.Output) .SetParameter("ErrorCode", System.Data.SqlDbType.NVarChar, DBNull.Value, 100, System.Data.ParameterDirection.Output) .SetParameter("ErrorMessage", System.Data.SqlDbType.NVarChar, DBNull.Value, 4000, System.Data.ParameterDirection.Output).GetList <TableOfContents>(out list).Complete(); if (list.Count > 0) { result.ItemList = list; } provider.GetOutValue("ErrorCode", out outCode) .GetOutValue("ErrorMessage", out outMessage) .GetOutValue("TotalRecords", out string totalRows); if (outCode != "0") { result.ErrorCode = outCode; result.ErrorMessage = outMessage; } else { result.ErrorCode = ""; result.ErrorMessage = ""; result.TotalRows = int.Parse(totalRows); } } catch (Exception ex) { result.ErrorMessage = ex.Message; } return(result); }
public async Task <ReturnResult <Log> > GetLogWithPaging(BaseCondition <Log> condition) { return(await logDAL.GetLogWithPaging(condition)); }
public ReturnResult <JobLevel> GetAllWithSearchPaging(BaseCondition <JobLevel> condition) { return(_jobLevelDAL.GetAllJobLevelWithPaging(condition)); }
public ReturnResult <Document> GetDocumentPaging(BaseCondition <DocumentSearch> condition) { var result = DocumentDAL.GetDocumentPaging(condition); return(result); }
public ReturnResult <DocumentPaging> GetPagingWithSearchResults(BaseCondition <DocumentPaging> condition) { var result = DocumentDAL.GetPagingWithSearchResults(condition); return(result); }
public IActionResult TinhTrangVatLyGetSearchWithPaging([FromBody] BaseCondition <TinhTrangVatLy> condition) { ReturnResult <TinhTrangVatLy> result = tinhTranhVatLyBUS.TinhTrangVatLyGetSearchWithPaging(condition); return(Ok(result)); }