2011-03-29 68 views
0

我有一個選擇實體SQL返回簡單的字符串,我應該連接到一個字符串。實體SQL連接

select (p.X + p.Y) from ExampleEntities.ExampleTable as p 
group by p.X, p.Y 

例如,它返回3個字符串,我應該將它連接到1個字符串。

回答

0

我不知道,如果你想連接的所有行或每行,但是這是一個每行的解決方案:

from p in ExampleEntities.ExampleTable 
select string.Concat(p.X, p.Y, p.Z) 

如果你想要一個結果,你會需要以下條件:

var temp = (from p in ExampleEntities.ExampleTable 
      select string.Concat(p.X, p.Y, p.Z)).ToList(); 

string result = temp.Aggregate((current, next) => current + next); 
+0

所以我想連接所有的「示例選擇」行到1個字符串。 – user682157 2011-03-29 16:23:40

+1

是的它是一個好主意,但你使用linq,我應該在實體sql中做到這一點。 – user682157 2011-03-30 16:17:11