Hi,
I have 3 tables :
item_saleable
* Id
item_saleable_distinction
* Id
* FK_item_saleable_Id (foreign key to item_saleable.Id)
* FK_item_distinction_type_Id (foreign key to item_distinction_type.Id)
item_distinction_type
* Id
* Text
I would like to use it to concatenate item_distinction_type.Text using the
GROUP_CONCAT MySQL function as in the following query.
SELECT FK_item_saleable_Id, GROUP_CONCAT(item_distinction_type.Text SEPARATOR '!')
FROM item_saleable_distinction
INNER JOIN item_distinction_type ON item_distinction_type.Id = item_saleable_distinction.FK_item_distinction_type_Id
GROUP BY FK_item_saleable_Id
but don't know how to write it in Linq.
My first idea was to add a GroupConcat function to the FunctionMappingStore like this
public class DatabaseFunctions : FunctionMappingStore
{
public DatabaseFunctions()
: base()
{
this.Add(new FunctionMapping(typeof(DatabaseFunctions), "GroupConcat", 1, "GROUP_CONCAT({0} SEPARATOR '!')"));
}
public static string GroupConcat(object arg1)
{
return string.Empty;
}
}
but in Linq when you use the group by clause, you can only use some limited functions as Min, Max, Average, Count, ...
Is there a way to add the **GroupConcat **to the **IGrouping **interface?
Note : you will find a sample project as an attachment
Attachments
Filename |
File size |
Added on |
Approval |
GroupConcatTest.zip
|
66,967 |
06-Jun-2012 14:18.42 |
Approved |