質問

I was using the same query before it was working fine. Then I decided to use complied query. So I had to make few changes to the code.

Now when I try to execute the code, I get the error message "Unsupported overload used for query operator 'Where'. The where clause which I generate from “approvalHelper.GetWhereClauseForApprovalSimpleSearch();” has been tested and works fine. Only doesn't work for the complied query part as shown in my code

code :

// Complied Query Class
public static class CompliedQuery
{

    public static Func<GDataContext, Expression<Func<View_ApprovalSimple, bool>>, IQueryable<View_ApprovalSimple>> getApprovalSimple =


    CompiledQuery.Compile<GDataContext, Expression<Func<View_ApprovalSimple, bool>>, IQueryable<View_ApprovalSimple>>(
           (db, whereclause) => (from results in db.View_ApprovalSimples.AsExpandable().Where(whereclause)
                                select results));        
}

// this is what is passed into the where clause; Body = {(vas.siteId = 1)}


//the Calling code
public static List<View_ApprovalSimple> GetApprovalSimple(ApprovalsSearchHelperClass _approvalHelper)
{
    Expression<Func<View_ApprovalSimple, bool>> whrClause = approvalHelper.GetWhereClauseForApprovalSimpleSearch();

    //whrclause; Body = {(vas.siteId = 1)}
    try
    {
        using (GDataContext db = new GDataContext())
        {
            if (whrClause != null)
            {
                var varResults = CompliedQuery.getApprovalSimple(db, whrClause);

                return varResults.ToList();
            }
        }  
    }
    catch (Exception ex)
    {
        // code to handle error        
    }
    finally
    {          
    }

    return null;    
}

Any idea what new changes I might have to implement?

Thanks in advance.

役に立ちましたか?

解決 2

First I was a bit sceptical about this, ran out of options so I finally tried it and it did work. please follow the link to see answer Steve's Blog Great work Steve.

他のヒント

Check the namespaces (start off by copying them all from CompliedQuery) to the calling class.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top