Comments (9)
Your query is wrong, you need to start from your collection (course) and manually map parent class properties. in the above example, you're doing it in reverse order.
also, gridify just converting your string to the actual expression, you should at least provide a Linq example of what you need to achieve.
from gridify.
from st in db.students
where st.courses.where(x=>x.name=="abcd").count()>0
select st
I am on students page ,that has a data grid.
user want filter students grid by it condition
from gridify.
exactly, if you have a two-way relation between students and courses you can simply switch your collections.
e.g:
var query = from course in db.courses
where course.Name == "abcd"
select course.Student
this way you can use gridify without problem because your query is normalized now. this query does exactly what you want.
and this way because your student relation is not a collection you can Add your mappings for the student entity.
var gm = new GridifyMapper<Course>()
.AddMap("CourseName", x=> x.Name)
.AddMap("StudentName", x=> x.Student.Name)
....
In the end, you should use Projection or select statement to get the students
from gridify.
Ok.
How do you do If i want add other conditiones related with student in one query ?
Tnx a lot
from gridify.
e.g
var gq = new GridifyQuery() { Filter = "Age<30 , StudentName^a , CourseName==abcd" , SortBy = "StudentName" };
var gm = new GridifyMapper<Course>()
.AddMap("CourseName", x=> x.Name)
.AddMap("StudentName", x=> x.Student.Name)
.AddMap("Age" , x=> x.Student.Age);
var query = db.Courses.ApplyFilterAndOrdering( gq ); // or use GridifyQueriable if you need pagination too
var result = query.Select(x=> x.Student).ToList(); // you can select anything here
from gridify.
tnx a lot
but a question !
what is query ?
get all students list! that can filter by multiple field by user! the customer wants me a filter on same list over related table( course)
with this solution i get all students that select minimum one course
this is not all real students list
Is that right?
from gridify.
Yes, it depends on what you want exactly there are few ways to write a single query. in this case, your main query was on CourseName
so it makes sense to select students related to the courses.
usually, if you want to select all students you shouldn't use filtering on courses.
these tricks help you implement 99 percent of scenarios, but I agree there are some edge cases you can't do much. (I never faced one yet though).
from gridify.
tnx a lot for replay
from gridify.
Your requested feature is available in the v2
.
from gridify.
Related Issues (20)
- RobiniaDocs API Explorer HOT 1
- Filtering on Double with different culture HOT 9
- Possibility to use Gridify (as parser) to create your own non-LINQ query builder HOT 2
- add support automatic mapping generation for child classes HOT 1
- Update documentation site dependencies (Vuepress2)
- Gridify.Elasticsearch generate DSL query (non-generic) HOT 3
- JavaScript client library HOT 3
- Creating an Abstractions Layer for Gridify
- Error "Specified method is not supported" when querying the Nested List field in Elasticsearch HOT 2
- DateTime Kind and PostgreSQL HOT 13
- IN style operator HOT 5
- Support for. NET8 HOT 4
- NativeAOT support
- Why library can not resolve IGridifyMapper<T> default in DbContext.ServiceProvider if exists HOT 1
- GRPC Support HOT 2
- Comparing data between two fields rather than using hardcoded values
- Cleanup dependencies HOT 2
- Filtering based on IDictionary values
- Passing filter value on CustomOperator Expression creation - for ContainsAny operator HOT 10
- Support automatic mapping generation for list of primitives
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gridify.