Code Monkey home page Code Monkey logo

Comments (9)

alirezanet avatar alirezanet commented on July 17, 2024

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.

masoodinfo avatar masoodinfo commented on July 17, 2024

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.

alirezanet avatar alirezanet commented on July 17, 2024

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.

masoodinfo avatar masoodinfo commented on July 17, 2024

Ok.
How do you do If i want add other conditiones related with student in one query ?
Tnx a lot

from gridify.

alirezanet avatar alirezanet commented on July 17, 2024

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.

masoodinfo avatar masoodinfo commented on July 17, 2024

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.

alirezanet avatar alirezanet commented on July 17, 2024

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.

masoodinfo avatar masoodinfo commented on July 17, 2024

tnx a lot for replay

from gridify.

alirezanet avatar alirezanet commented on July 17, 2024

Your requested feature is available in the v2.

from gridify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.