Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
This is Mrugesh from Bharti. We are developing an enterprise version of the application for our clients. What I have observed that my team is spending quite lots of time developing Get API for any entity. When I look at the code, it's quite repeated.

I tried System.Linq.Dynamic to create GET Data layer which permits an end-user to pass on expected columns.

See my intention to do so is,

Have a single GET API
Take columns names as parameters
I already have dynamic filters working for me. So the user can pass on filter parameters.

Ultimately, we won't be creating get variations.

What I have tried:

C#
<pre>  

//This code works perfectly for 1-1 relationship. Here we can get EDMX or DTO object collection. The issue is getting 1 to n relationship.

IQueryable<Quickscrum.Models.EDMX.Employee> query = EDMXInstance.Context.Employees;
List<Quickscrum.Models.EDMX.Employee> employeeCollection = new List<Quickscrum.Models.EDMX.Employee>();
query = query.Where(FilterBuilder.GetDynamicQuery<Quickscrum.Models.EDMX.Employee>("Id, Name, Description, EmployeeDepartmentId, EmployeeDepartment.Id, EmployeeDepartment.Name, EmployeeDepartment.Description, EmployeeLocation.CityName"));
employeeCollection.AddRange(query.ToList()); 
return employeeCollection;
Posted
Comments
[no name] 3-Aug-19 15:14pm    
Looks like you're using outdated EF patterns ("EDMX").

And you've lost compile time entity property name checking. Might as well write stored procs.

I expect your development time to increase, not decrease.
Richard Deeming 8-Aug-19 13:52pm    
Are you looking for something like GraphQL[^]?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900