public void Select_Credits_From_Lookups_Table_In_Descending_Order_From_DropDownListRequest_As_Anonymous_Type() { //arrange var selectorLambdaOperatorDescriptor = GetExpressionDescriptor <IQueryable <LookUpsModel>, IEnumerable <dynamic> > ( GetBodyForAnonymousType(), "q" ); IMapper mapper = serviceProvider.GetRequiredService <IMapper>(); ISchoolRepository repository = serviceProvider.GetRequiredService <ISchoolRepository>(); //act var expression = mapper.MapToOperator(selectorLambdaOperatorDescriptor).Build(); var list = RequestHelpers.GetAnonymousSelect ( new Business.Requests.GetAnonymousDropDownListRequest { Selector = selectorLambdaOperatorDescriptor, ModelType = typeof(LookUpsModel).AssemblyQualifiedName, DataType = typeof(LookUps).AssemblyQualifiedName }, repository, mapper ).Result.DropDownList.ToList(); //assert AssertFilterStringIsCorrect(expression, "q => Convert(q.Where(l => (l.ListName == \"Credits\")).OrderByDescending(l => l.NumericValue).Select(l => new AnonymousType() {NumericValue = l.NumericValue, Text = l.Text}))"); Assert.Equal(5, list.Count); }
public void Select_Departments_In_Ascending_Order_As_Anonymous_Type() { //arrange var selectorLambdaOperatorDescriptor = GetExpressionDescriptor <IQueryable <DepartmentModel>, IEnumerable <dynamic> > ( GetDepartmentsBodyForLookupModelType(), "q" ); IMapper mapper = serviceProvider.GetRequiredService <IMapper>(); ISchoolRepository repository = serviceProvider.GetRequiredService <ISchoolRepository>(); //act var expression = mapper.MapToOperator(selectorLambdaOperatorDescriptor).Build(); var list = RequestHelpers.GetAnonymousSelect <DepartmentModel, Department> ( new Business.Requests.GetAnonymousDropDownListRequest { Selector = selectorLambdaOperatorDescriptor, ModelType = typeof(DepartmentModel).AssemblyQualifiedName, DataType = typeof(Department).AssemblyQualifiedName }, repository, mapper ).Result.DropDownList.ToList(); //assert AssertFilterStringIsCorrect(expression, "q => Convert(q.OrderBy(d => d.Name).Select(d => new LookUpsModel() {NumericValue = Convert(d.DepartmentID), Text = d.Name}))"); Assert.Equal(4, list.Count); }
public async Task <GetAnonymousDropDownListResponse> GetAnonymousDropdown([FromBody] GetAnonymousDropDownListRequest request) { return(await RequestHelpers.GetAnonymousSelect ( request, repository, mapper )); }