public void Select_Instructors_In_Ascending_Order_As_InstructorModel_Type() { //arrange var selectorLambdaOperatorDescriptor = GetExpressionDescriptor <IQueryable <InstructorModel>, IEnumerable <InstructorModel> > ( GetInstructorsBody(), "q" ); IMapper mapper = serviceProvider.GetRequiredService <IMapper>(); ISchoolRepository repository = serviceProvider.GetRequiredService <ISchoolRepository>(); //act var expression = mapper.MapToOperator(selectorLambdaOperatorDescriptor).Build(); var list = RequestHelpers.GetObjectSelect <InstructorModel, Instructor, IEnumerable <InstructorModel>, IEnumerable <Instructor> > ( new Business.Requests.GetTypedDropDownListRequest { Selector = selectorLambdaOperatorDescriptor, ModelType = typeof(InstructorModel).AssemblyQualifiedName, DataType = typeof(Instructor).AssemblyQualifiedName, ModelReturnType = typeof(IEnumerable <InstructorModel>).AssemblyQualifiedName, DataReturnType = typeof(IEnumerable <Instructor>).AssemblyQualifiedName }, repository, mapper ).Result.DropDownList.ToList(); //assert AssertFilterStringIsCorrect(expression, "q => Convert(q.OrderBy(d => d.FullName).Select(d => new InstructorModel() {ID = d.ID, FirstName = d.FirstName, LastName = d.LastName, FullName = d.FullName}))"); Assert.Equal(5, list.Count); Assert.Equal("Candace Kapoor", ((InstructorModel)list.First()).FullName); }
public void Select_Credits_From_Lookups_Table_In_Descending_Order_From_DropDownListRequest_As_LookUpsModel_Using_Object_ReturnType() { //arrange var selectorLambdaOperatorDescriptor = GetExpressionDescriptor <IQueryable <LookUpsModel>, IEnumerable <LookUpsModel> > ( GetBodyForLookupsModel(), "q" ); IMapper mapper = serviceProvider.GetRequiredService <IMapper>(); ISchoolRepository repository = serviceProvider.GetRequiredService <ISchoolRepository>(); //act var expression = mapper.MapToOperator(selectorLambdaOperatorDescriptor).Build(); var list = RequestHelpers.GetObjectSelect ( new Business.Requests.GetTypedDropDownListRequest { Selector = selectorLambdaOperatorDescriptor, ModelType = typeof(LookUpsModel).AssemblyQualifiedName, DataType = typeof(LookUps).AssemblyQualifiedName, ModelReturnType = typeof(IEnumerable <LookUpsModel>).AssemblyQualifiedName, DataReturnType = typeof(IEnumerable <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 LookUpsModel() {NumericValue = l.NumericValue, Text = l.Text}))"); Assert.Equal(5, list.Count); }
public void Select_Departments_In_Ascending_Order_As_DepartmentModel_Type() { //arrange var selectorLambdaOperatorDescriptor = GetExpressionDescriptor <IQueryable <DepartmentModel>, IEnumerable <DepartmentModel> > ( GetDepartmentsBodyForDepartmentModelType(), "q" ); IMapper mapper = serviceProvider.GetRequiredService <IMapper>(); ISchoolRepository repository = serviceProvider.GetRequiredService <ISchoolRepository>(); //act var expression = mapper.MapToOperator(selectorLambdaOperatorDescriptor).Build(); var list = RequestHelpers.GetObjectSelect <DepartmentModel, Department, IEnumerable <DepartmentModel>, IEnumerable <Department> > ( new Business.Requests.GetTypedDropDownListRequest { Selector = selectorLambdaOperatorDescriptor, ModelType = typeof(DepartmentModel).AssemblyQualifiedName, DataType = typeof(Department).AssemblyQualifiedName, ModelReturnType = typeof(IEnumerable <DepartmentModel>).AssemblyQualifiedName, DataReturnType = typeof(IEnumerable <Department>).AssemblyQualifiedName }, repository, mapper ).Result.DropDownList.ToList(); //assert AssertFilterStringIsCorrect(expression, "q => Convert(q.OrderBy(d => d.Name).Select(d => new DepartmentModel() {DepartmentID = d.DepartmentID, Name = d.Name}))"); Assert.Equal(4, list.Count); }
public async Task <GetObjectDropDownListResponse> GetObjectDropDown([FromBody] GetTypedDropDownListRequest request) { return(await RequestHelpers.GetObjectSelect ( request, repository, mapper )); }