1

I have two long type columns that I want to concat during sql query. Using Linq to Entities making it impossible, because it only supports String.Concat(string, string).

I'd like to know how can I implement this function myself and add it to the L2E framework.

Eran Betzalel
  • 4,105
  • 3
  • 38
  • 66

2 Answers2

1

What's the point in doing the concat in SQL ? You can do it in a projection when you receive the data :

var query = from foo in db.Foo
            select new { foo.X, foo.Y };

var result = from foo in query.AsEnumerable()
             select foo.X.ToString() + foo.Y.ToString();

I'd like to know how can I implement this function myself and add it to the L2E framework.

I don't think that's possible, unless you want to implement your own EF provider...

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
0

Can't you convert them to strings first, by doing String.Concat(long1.ToString(), long2.ToString())? Or is this not understood by the framework either?

Take a look at this question, which talks about some workarounds for this problem. Maybe you can adapt something to work here as well?

Community
  • 1
  • 1
lc.
  • 113,939
  • 20
  • 158
  • 187
  • ToString() is not supported by L2E. Look here: http://msdn.microsoft.com/en-us/library/bb738681.aspx – Eran Betzalel Jun 03 '10 at 09:03
  • @Eran Betzalel I see. After a bit of digging, this looks like a common problem - there are a few related questions on SO. Not sure if it's helpful, but would be at least worth a look. – lc. Jun 03 '10 at 09:13
  • The solution on these questions is not for me (my current situation suggests that using ToList will simply get all the table's content). – Eran Betzalel Jun 03 '10 at 10:45