Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
SolvedPrivate

Need to add Where to this LINQ expression

Posted on 2014-02-12
10
Medium Priority
?
71 Views
Last Modified: 2016-02-10
return base.QueryOver(query).
                    WhereRestrictionOn(x => x.DealerId).
                    OrderBy(x => x.SortOrder).Asc;


I need to add Where(x  => x.Status == true)

but do not know how to ad this correctly since there is already a call to WhereRestrictionOn
0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 1000 total points
ID: 39854307
Not sure if this will work:
WhereRestrictionOn(x => x.DealerId && x.Status == true)

but you can chain the where:
return base.QueryOver(query).
                    WhereRestrictionOn(x => x.DealerId).
                    Where(x => x.Status == true).
                    OrderBy(x => x.SortOrder).Asc;
0
 
LVL 19

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 500 total points
ID: 39854319
return base.QueryOver(query).
                    WhereRestrictionOn(x => (x.DealerId) &&  (x => x.Status == true)).
                    OrderBy(x => x.SortOrder).Asc;
0
 

Author Comment

by:newbieweb
ID: 39854350
I tried these all prior to posting, but none works
0
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 1000 total points
ID: 39854500
does status have a value?  and is it actually "true" or is it 1 ?
0
 

Author Comment

by:newbieweb
ID: 39854516
It actually checks against an enumerate values, but the syntax is failing so I just used a book in this quersion.
0
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39854587
A couple of questions. Is this using NHibernate?

Is the query you posted complete? For example the examples I have seen have something like this:

WhereRestrictionOn(x => x.DealerId).IsBetween(2).And(8)
0
 

Author Comment

by:newbieweb
ID: 39854605
So sorry, YES this is NHibernate.
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 39854610
Also if your original query is actually working then did you try putting the Where before WhereRestrictionOn as shown below?

return base.QueryOver(query).
            Where(x  => x.Status == true).
            WhereRestrictionOn(x => x.DealerId).
            OrderBy(x => x.SortOrder).Asc;

Open in new window

0
 

Author Comment

by:newbieweb
ID: 39854615
AndRestrictionOn() solves the problem
0
 

Author Closing Comment

by:newbieweb
ID: 39854618
thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question