I am working with MongoDb
, and is using PredicateBuilder
class for creating where clause dynamically IN C#. But the exception gets generated as :
[System.ArgumentException] {"Unsupported where clause: ."} ,
and the dynamically generated where clause is
{c => (True AndAlso Invoke(c => (c.ID == value(ASP.search_aspx).txtid.Text), c))} ,
Query Used:
var result = collection.AsQueryable<USER>()
.Where(where_clause)
.Select(c => new { c.ID, c.COMPANYNAME, c.EMAIL
}).Take(100).ToList();
collection is the instance is MongoCollection
.
Code for creating where_clause
:
var where_clause = PredicateBuilder.True<GLUSR_USR>();
//object result=0;
if ((txtGlid.Text).Trim() != "")
{
where_clause = where_clause.And(c => c.GLUSR_USR_ID == txtGlid.Text);
}
if ((txtEmailid.Text).Trim() != "")
{
where_clause = where_clause.And(c => c.GLUSR_USR_EMAIL == txtEmailid.Text);
}
if ((txtPhone.Text).Trim() != "")
{
where_clause = where_clause.And(c => c.GLUSR_USR_PH_NUMBER == txtPhone.Text);
}
if ((txtMobile.Text).Trim() != "")
{
where_clause = where_clause.And(c => c.GLUSR_USR_PH_MOBILE == txtMobile.Text);
}