I have a similar problem (also related to Predicate Building)
 
I defined an expression...
 
    public static Expression<Func<RequiredDevice, bool>> HasWorkstationTag(
string workstation, string tag)
    {
         string w = workstation.ToLower(), t = tag.ToLower();
         var predicate = PredicateBuilder.True<RequiredDevice>();
         predicate = predicate.And(x => x.InstanceTag.ToLower() == t);
         predicate = predicate.And(x => x.WorkstationId.ToLower() == w);
         return predicate;
    }
 
... and query which receives an Expression ...
 
    public IEnumerable<IRequiredDevice> GetDeviceConfigs(IUser user, 
Expression<Func<RequiredDevice, bool>> where)
    {
         List<IRequiredDevice> list = new List<IRequiredDevice>();
         list.AddRange(Context.GetSession().QueryOver<RequiredDevice>()
             .Where(where)
             .List());
         return list;
    }
 
... and call the query using the Expression ...
 
    IRequiredDevice config = appManager.PersistenceManager.GetDeviceConfigs(
        user, RequiredDeviceLinq.HasWorkstationTag(workstation.Name, rd.
InstanceTag)).FirstOrDefault();

 
... the result ...
 
Atf.NUnit.Model.TestTarget.TestDeviceConfig():
System.Exception : Could not determine member type from Constant, True, 
System.Linq.Expressions.ConstantExpression

... which I'm guessing comes from Expression method
 
var predicate = PredicateBuilder.True<RequiredDevice>();
 
Why is this a problem? Is there a workaround?





On Friday, 10 May 2013 17:16:44 UTC+2, [email protected] wrote:

> using  NHibernate.dll, v3.3.1.4000
>  
> try this....
>  
>  
>
> session.QueryOver<model>().Where(param => true);
>  
> throws error:
>  
> Could not determine member type from Constant, True, 
> System.Linq.Expressions.ConstantExpression
>  
>  
> Don't ask why I want to do that... trust me - there is a reason I need to 
> do this related to predicate building.
>  
>  
>  
>  
>  
>  
>  
>  
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to