SolvedPrivate

Need to add Where to this LINQ expression

Posted on 2014-02-12
10
65 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 250 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 125 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 250 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 63

Accepted Solution

by:
Fernando Soto earned 125 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 63

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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