我是linq的新手..我想连接字符串..我们如何连接以下查询的字符串..帮助我 [英] I am novice to linq..I want to concatenate the strings ..How can we concatenate the strings for the below query..help me
本文介绍了我是linq的新手..我想连接字符串..我们如何连接以下查询的字符串..帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此处LicenseId为整数..
var q =(来自salesContext.SL_License中的b,其中b.OrderId == 254857选择新{b.LicenseId}) .ToList();
解决方案
你可以使用string.Join
< pre lang =c#> var q =(.....)。ToList();
var res = string .Join( ,,q);
LINQAggregate
可用于连接字符串的扩展方法。
string [] array = { a, b};
var output = array.Aggregate((a,b)= > a + b );
以下是一些例子 -
C#聚合方法 [ ^ ]
有关聚合方法的更多信息 [ ^ ]
here LicenseId is Integer..
var q = (from b in salesContext.SL_License where b.OrderId == 254857 select new { b.LicenseId}).ToList();
解决方案
you can usestring.Join
var q = (.....).ToList(); var res = string.Join(",",q);
LINQ has anAggregate
extension method that can be used to concatenate strings.
string[] array = { "a", "b"}; var output = array.Aggregate((a, b) => a + b);
Here are some more examples -
C# Aggregate method[^]
More on the Aggregate method[^]
这篇关于我是linq的新手..我想连接字符串..我们如何连接以下查询的字符串..帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文