This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am trying to run a query as below, but not having any joy and am getting "the method or operation is not implemented". Have I missed something, or is this not possible ? public IList<Supplier> GetAllSuppliers(bool enabledOnly) The equivalent SQL below is what I'm after, where if @enabledOnly is false, everything is returned, whereas if it is true, only rows where the Enabled field = True are returned. DECLARE @enabledOnly bit SET @enabledOnly = 0 SELECT * FROM Supplier WHERE (Enabled = @enabledOnly OR @enabledOnly = 0) I can easily put the condition outside the actual query and have two queries as below, but was trying to be a bit more compact. if (enabledOnly)
Cheers Paul |
|
|
This looks like a bug in our handling of "enabledOnly == false" -- LINQ is asking LightSpeed to construct a query expression from a local variable and a literal value, but LightSpeed only knows how to construct query expressions around columns (entity properties). You can get the effect you want in a single query as follows: Instance.Suppliers.Where(s => (s.Enabled == true) || (s.Enabled == enabledOnly)).OrderBy... |
|