Thanks guys! Your new binary fixed the problem.
But now there is another problem. I have isolated it to calling mapped db functions with group key's property.
Here are the queries against NW database. The first query works but the second fails.
LinqMetaData metaData = new LinqMetaData(adapter);
metaData.CustomFunctionMappings = new DbFunctionMappings();
//group by one field, then call function, use the key as parameter
// works
var result1 = from em in metaData.Employees
group em by em.City into q
select new { city = q.Key, UPPERCITY = DbFunctions.TOUPPER(q.Key) };
IList list1 = result1.ToList();
//group by two fields, then call function use one of the keys as parameter
// got exception
var result2 = from em in metaData.Employees
group em by new { em.City, em.Country } into q
select new { city = q.Key.City, UPPERCITY = DbFunctions.TOUPPER(q.Key.City) };
IList list2 = result2.ToList();
Here is the function mapping that we made.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Northwind.EntityClasses;
using Northwind.Linq;
using Northwind.DatabaseSpecific;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Collections;
namespace LLBLTest
{
/// Class which is used to specify the call to the database function. We'll map
/// the function inside it, CalculateOrderTotal, to the database function.
public class DbFunctions
{
/// <summary>
/// change string to upper case
/// </summary>
/// <param name="str">string.</param>
/// <returns></returns>
public static string TOUPPER(string str)
{
// empty body, as it's just here to make the query compile. The call is converted to a SQL function.
return "";
}
}
public class DbFunctionMappings : FunctionMappingStore
{
public DbFunctionMappings()
: base()
{
this.Add(new FunctionMapping(typeof(DbFunctions), "TOUPPER", 1, "UPPER({0})"));
}
}
}