Ejemplo n.º 1
0
 public SelectorLambdaOperatorParameters(IExpressionParameter selector, Type sourceElementType, string parameterName, Type bodyType = null)
 {
     Selector          = selector;
     SourceElementType = sourceElementType;
     ParameterName     = parameterName;
     BodyType          = bodyType;
 }
 private IExpressionParameter GetFilterParameter <T>(IExpressionParameter selectorBody, string parameterName = "$it")
 => new FilterLambdaOperatorParameters
 (
     selectorBody,
     typeof(T),
     parameterName
 );
        public void Delete_A_Single_Entity_Using_Delete()
        {
            //arrange
            var bodyParameter = new EqualsBinaryOperatorParameters
                                (
                new MemberSelectorOperatorParameters("FullName", new ParameterOperatorParameters(parameterName)),
                new ConstantOperatorParameters("Carson Alexander")
                                );

            //act
            DoTest <StudentModel, Student>
            (
                bodyParameter,
                null,
                null,
                parameterName,
                (StudentModel studentModel, ISchoolRepository repository) =>
            {
                IExpressionParameter expressionParameter           = GetFilterParameter <StudentModel>(bodyParameter, parameterName);
                Expression <Func <StudentModel, bool> > expression = ProjectionOperations <StudentModel, Student> .GetFilter
                                                                     (
                    serviceProvider.GetRequiredService <IMapper>().MapToOperator(expressionParameter)
                                                                     );

                PersistenceOperations <StudentModel, Student> .Delete(repository, expression);
            },
                returnValue =>
            {
                Assert.Null(returnValue);
            },
                "$it => ($it.FullName == \"Carson Alexander\")"
            );
        }
        void DoTest <TModel, TData>(IExpressionParameter bodyParameter,
                                    IExpressionParameter queryFunc,
                                    SelectExpandDefinitionParameters expansion,
                                    string parameterName,
                                    Action <TModel, ISchoolRepository> update,
                                    Action <TModel> assert,
                                    string expectedExpressionString) where TModel : LogicBuilder.Domain.BaseModel where TData : LogicBuilder.Data.BaseData
        {
            //arrange
            IMapper              mapper              = serviceProvider.GetRequiredService <IMapper>();
            ISchoolRepository    repository          = serviceProvider.GetRequiredService <ISchoolRepository>();
            IExpressionParameter expressionParameter = GetFilterParameter <TModel>(bodyParameter, parameterName);

            TestExpressionString();
            TestReturnValue();

            void TestReturnValue()
            {
                //act
                TModel returnValue = ProjectionOperations <TModel, TData> .Get
                                     (
                    repository,
                    mapper,
                    expressionParameter,
                    queryFunc,
                    expansion
                                     );

                update(returnValue, repository);

                returnValue = ProjectionOperations <TModel, TData> .Get
                              (
                    repository,
                    mapper,
                    expressionParameter,
                    queryFunc,
                    expansion
                              );

                //assert
                assert(returnValue);
            }

            void TestExpressionString()
            {
                //act
                Expression <Func <TModel, bool> > expression = ProjectionOperations <TModel, TData> .GetFilter
                                                               (
                    mapper.MapToOperator(expressionParameter)
                                                               );

                //assert
                if (!string.IsNullOrEmpty(expectedExpressionString))
                {
                    AssertFilterStringIsCorrect(expression, expectedExpressionString);
                }
            }
        }
Ejemplo n.º 5
0
 public static TModelReturn Query(IContextRepository repository,
                                  IMapper mapper,
                                  IExpressionParameter queryExpression,
                                  SelectExpandDefinitionParameters expansion = null)
 => repository.QueryAsync <TModel, TData, TModelReturn, TDataReturn>
 (
     GetQueryFunc(mapper.MapToOperator(queryExpression)),
     mapper.MapExpansion(expansion)
 ).Result;
Ejemplo n.º 6
0
 public static ICollection <TModel> GetItems(IContextRepository repository,
                                             IMapper mapper,
                                             IExpressionParameter filterExpression      = null,
                                             IExpressionParameter queryFunc             = null,
                                             SelectExpandDefinitionParameters expansion = null)
 => repository.GetAsync <TModel, TData>
 (
     GetFilter(mapper.MapToOperator(filterExpression)),
     GetQueryFunc(mapper.MapToOperator(queryFunc)),
     mapper.MapExpansion(expansion)
 ).Result;
Ejemplo n.º 7
0
 public static TModel Get(IContextRepository repository,
                          IMapper mapper,
                          IExpressionParameter filterExpression,
                          IExpressionParameter queryFunc             = null,
                          SelectExpandDefinitionParameters expansion = null)
 => GetItems
 (
     repository,
     mapper,
     filterExpression,
     queryFunc,
     expansion
 ).SingleOrDefault();
        public MemberSelectorOperatorParameters
        (
            [ParameterEditorControl(ParameterControlType.ParameterSourcedPropertyInput)]
            [NameValue(AttributeNames.PROPERTYSOURCEPARAMETER, "fieldTypeSource")]
            [Comments("Update fieldTypeSource first. Full or parial member name from the source operand parent.")]
            string memberFullName,

            [Comments("Source Operand.")]
            IExpressionParameter sourceOperand,

            [ParameterEditorControl(ParameterControlType.ParameterSourceOnly)]
            [NameValue(AttributeNames.DEFAULTVALUE, "Enrollment.Domain.Entities")]
            [Comments("Fully qualified class name for the model type.")]
            string fieldTypeSource = null
        )
        {
            MemberFullName = memberFullName;
            SourceOperand  = sourceOperand;
        }
        public MemberBindingItem
        (
            [NameValue(AttributeNames.USEFOREQUALITY, "true")]
            [NameValue(AttributeNames.USEFORHASHCODE, "true")]
            [ParameterEditorControl(ParameterControlType.ParameterSourcedPropertyInput)]
            [NameValue(AttributeNames.PROPERTYSOURCEPARAMETER, "fieldTypeSource")]
            [Comments("Update fieldTypeSource first. Property to bind the selector to.")]
            string property,

            [Comments("Selector.")]
            IExpressionParameter selector,

            [ParameterEditorControl(ParameterControlType.ParameterSourceOnly)]
            [NameValue(AttributeNames.DEFAULTVALUE, "Contoso.Domain.Entities")]
            [Comments("Fully qualified class name for the model type.")]
            string fieldTypeSource = null
        )
        {
            Property = property;
            Selector = selector;
        }
Ejemplo n.º 10
0
 public TrimOperatorParameter(IExpressionParameter operand)
 {
     Operand = operand;
 }
Ejemplo n.º 11
0
 public TakeOperatorParameter(IExpressionParameter sourceOperand, int count)
 {
     SourceOperand = sourceOperand;
     Count         = count;
 }
Ejemplo n.º 12
0
 public WhereOperatorParameters(IExpressionParameter sourceOperand, IExpressionParameter filterBody, string filterParameterName) : base(sourceOperand, filterBody, filterParameterName)
 {
 }
 public SubstringOperatorParameter(IExpressionParameter sourceOperand, params IExpressionParameter[] indexes)
 {
     SourceOperand = sourceOperand;
     Indexes       = indexes;
 }
Ejemplo n.º 14
0
 public FractionalSecondsOperatorParameter(IExpressionParameter operand)
 {
     Operand = operand;
 }
 public DivideBinaryOperatorParameters(IExpressionParameter left, IExpressionParameter right) : base(left, right)
 {
 }
Ejemplo n.º 16
0
 public ConvertToNullableUnderlyingValueOperatorParameters(IExpressionParameter sourceOperand)
 {
     SourceOperand = sourceOperand;
 }
 public FirstOrDefaultOperatorParameter(IExpressionParameter sourceOperand, IExpressionParameter filterBody = null, string filterParameterName = null) : base(sourceOperand, filterBody, filterParameterName)
 {
 }
Ejemplo n.º 18
0
 public ConvertToNumericDateOperatorParameters(IExpressionParameter sourceOperand)
 {
     SourceOperand = sourceOperand;
 }
Ejemplo n.º 19
0
 public GreaterThanBinaryOperatorParameters(IExpressionParameter left, IExpressionParameter right) : base(left, right)
 {
 }
Ejemplo n.º 20
0
 public InOperatorParameter(IExpressionParameter itemToFind, IExpressionParameter listToSearch)
 {
     ItemToFind   = itemToFind;
     ListToSearch = listToSearch;
 }
 public ConcatOperatorParameter(IExpressionParameter left, IExpressionParameter right)
 {
     Left  = left;
     Right = right;
 }
Ejemplo n.º 22
0
 public static IExpressionPart MapToOperator(this IMapper mapper, IExpressionParameter expression)
 => mapper.MapToOperator
 (
     mapper.Map <OperatorDescriptorBase>(expression)
 );
 public DistinctOperatorParameter(IExpressionParameter sourceOperand)
 {
     SourceOperand = sourceOperand;
 }
Ejemplo n.º 24
0
 public BinaryOperatorParameters(IExpressionParameter left, IExpressionParameter right)
 {
     Left  = left;
     Right = right;
 }
 public DayOperatorParameters(IExpressionParameter operand)
 {
     Operand = operand;
 }
 public TotalSecondsOperatorParameters(IExpressionParameter operand)
 {
     Operand = operand;
 }
 public IEnumerableSelectorLambdaOperatorParameters(IExpressionParameter selector, Type sourceElementType, string parameterName)
 {
     Selector          = selector;
     SourceElementType = sourceElementType;
     ParameterName     = parameterName;
 }
Ejemplo n.º 28
0
 public ThenByOperatorParameters(IExpressionParameter sourceOperand, IExpressionParameter selectorBody, ListSortDirection sortDirection, string selectorParameterName) : base(sourceOperand, selectorBody, selectorParameterName)
 {
     SortDirection = sortDirection;
 }
Ejemplo n.º 29
0
 public SingleOperatorParameters(IExpressionParameter sourceOperand, IExpressionParameter filterBody = null, string filterParameterName = null) : base(sourceOperand, filterBody, filterParameterName)
 {
 }
Ejemplo n.º 30
0
 public OrBinaryOperatorParameter(IExpressionParameter left, IExpressionParameter right) : base(left, right)
 {
 }