views:

28

answers:

1

Any time I use the code below it throws the error:

Method 'System.String Join(System.String, System.Collections.Generic.IEnumerable`1[System.String])' has no supported translation to SQL.

        var items = from t in fc.table
                    where t.id== objId
                    select new
                    {
                        t.id,
                        t.name,
                        string.Join(...)
                    };

I tried using the LINQ Aggregate method but got a similar error. Any suggestions on ways to get the string.Join functionality without the error?

Also, this code compiles fine. It's when I try to do something with items that it throws the error.

+1  A: 

Force the query to run on the client first, to extract the raw data, then join the strings in memory:

    var items = from a in (from t in fc.table
                           where t.id== objId
                           select new
                           {
                               t.id,
                               t.name,
                               t.a, t.b, t.c
                           }).AsEnumerable()
                select new
                {
                    a.id, 
                    a.name, 
                    string.Join(",", new[] { a.a, a.b. a.c })
                };
Tim Robinson