The ABC method on the type XYZ isn't convertable to an LLBLGen Pro construct.

Posts   
 
    
AlbertK
User
Posts: 44
Joined: 23-Dec-2009
# Posted on: 10-Jul-2014 18:22:28   

Hello, I'm using 4.2 runtime and I created a function mapping to call FTS contains method on SQL Server. I'm getting the following error. Please help!

The Contains method on the type SQLFunctions isn't convertable to an LLBLGen Pro construct.

The code is this: var x = new LinqMetaData(a); x.CustomFunctionMappings = new SQLFunctionMappings(); var q = from m in x.MyTable where SQLFunctions.Contains(m.MyField, "test") select m; var results = q.ToList();

The mapping is defined like this:

    
public class SQLFunctionMappings : FunctionMappingStore
    {
        public SQLFunctionMappings()
            : base()
        {
            this.Add(new FunctionMapping
                (
                typeof(SQLFunctions),
                "Contains",
                2,
                "Contains({0}, {1})")
                );
        }
    }

    
public class SQLFunctions
    {
        public static bool Contains(string column, string expression)
        {
           return false;
        }
    }

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Jul-2014 06:04:11   

I think it's confused to the Method Call Expression Naming Handler when it sees a 'Contains' expression as the function mapping name. Please try to change it to another name. Like:

public class SQLFunctions
{
    public static bool FullTextSearch(string column, string expression)
    {
        return false;
    }
}

public class SQLFunctionMappings : FunctionMappingStore
{
    public SQLFunctionMappings()
        : base()
    {
        this.Add(new FunctionMapping
            (typeof(SQLFunctions), "FullTextSearch", 2, "Contains({0}, {1})") );
    }
}

...

var x = new LinqMetaData(a);
    x.CustomFunctionMappings = new SQLFunctionMappings();
    var q = from m in x.MyTable
            where SQLFunctions.FullTextSearch(m.MyField, "test")
            select m;
    var results = q.ToList();
}
David Elizondo | LLBLGen Support Team
AlbertK
User
Posts: 44
Joined: 23-Dec-2009
# Posted on: 14-Jul-2014 16:18:52   

Thank you so much. That was it! After renaming the function method, it worked just fine.