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); } } }
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;
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;
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; }
public TrimOperatorParameter(IExpressionParameter operand) { Operand = operand; }
public TakeOperatorParameter(IExpressionParameter sourceOperand, int count) { SourceOperand = sourceOperand; Count = count; }
public WhereOperatorParameters(IExpressionParameter sourceOperand, IExpressionParameter filterBody, string filterParameterName) : base(sourceOperand, filterBody, filterParameterName) { }
public SubstringOperatorParameter(IExpressionParameter sourceOperand, params IExpressionParameter[] indexes) { SourceOperand = sourceOperand; Indexes = indexes; }
public FractionalSecondsOperatorParameter(IExpressionParameter operand) { Operand = operand; }
public DivideBinaryOperatorParameters(IExpressionParameter left, IExpressionParameter right) : base(left, right) { }
public ConvertToNullableUnderlyingValueOperatorParameters(IExpressionParameter sourceOperand) { SourceOperand = sourceOperand; }
public FirstOrDefaultOperatorParameter(IExpressionParameter sourceOperand, IExpressionParameter filterBody = null, string filterParameterName = null) : base(sourceOperand, filterBody, filterParameterName) { }
public ConvertToNumericDateOperatorParameters(IExpressionParameter sourceOperand) { SourceOperand = sourceOperand; }
public GreaterThanBinaryOperatorParameters(IExpressionParameter left, IExpressionParameter right) : base(left, right) { }
public InOperatorParameter(IExpressionParameter itemToFind, IExpressionParameter listToSearch) { ItemToFind = itemToFind; ListToSearch = listToSearch; }
public ConcatOperatorParameter(IExpressionParameter left, IExpressionParameter right) { Left = left; Right = right; }
public static IExpressionPart MapToOperator(this IMapper mapper, IExpressionParameter expression) => mapper.MapToOperator ( mapper.Map <OperatorDescriptorBase>(expression) );
public DistinctOperatorParameter(IExpressionParameter sourceOperand) { SourceOperand = sourceOperand; }
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; }
public ThenByOperatorParameters(IExpressionParameter sourceOperand, IExpressionParameter selectorBody, ListSortDirection sortDirection, string selectorParameterName) : base(sourceOperand, selectorBody, selectorParameterName) { SortDirection = sortDirection; }
public SingleOperatorParameters(IExpressionParameter sourceOperand, IExpressionParameter filterBody = null, string filterParameterName = null) : base(sourceOperand, filterBody, filterParameterName) { }
public OrBinaryOperatorParameter(IExpressionParameter left, IExpressionParameter right) : base(left, right) { }