草庐IT

group_concat

全部标签

c# - 查询主体必须以 select 子句或 group 子句结尾为什么这里会出错?

我的linq语句有什么问题,我做错了什么?if(this.selectLBU.HtUsers.Any()){reportRowItems=(fromrinreportRowItemsfrombuinr.User.HtBusinessUnitswherebu.LocationBusinessUnitId==selectLBU.LocationBusinessUnitId).ToList(); 最佳答案 您需要添加select子句来告诉您需要从查询中获取哪些数据。这msdnarticle描述了基本的查询操作和结构。reportRowIt

c# - IEnumerable Group 按用户指定的动态键列表

我有一个类publicclassEmpolyee{publicstringDesignation{get;set;}publicstringDiscipline{get;set;}publicintScale{get;set;}publicDateTimeDOB{get;set;}publicintSales{get;set;}}并以可枚举的方式记录所有员工ListEmployees;和一个字符串键列表,例如varKeys=newList(){"Designation","Scale","DOB"};假设列表“键”的元素是用户指定的,用户可以不指定或指定多个键元素。现在我想使用列表“K

c# - 如何在 Linq to SQL 中使用 distinct 和 group by

我正在尝试将以下sql转换为Linq2SQL:selectgroupId,count(distinct(userId))fromprocessroundissueinstancegroupbygroupId这是我的代码:varq=fromiinProcessRoundIssueInstancegroupibyi.GroupIDintogselectnew{Key=g.Key,Count=g.Select(x=>x.UserID).Distinct().Count()};当我运行代码时,我不断收到无效的GroupID。有任何想法吗?似乎distinct把事情搞砸了..这里是生成的sql:

c# - VB.NET linq group by 匿名类型不能按预期工作

我正在研究LINQPad附带的一些linq示例。在“C#3.0inaNutshell”文件夹中的Chater9-Grouping下,有一个名为“GroupingbyMultipleKeys”的示例查询。它包含以下查询:fromninnew[]{"Tom","Dick","Harry","Mary","Jay"}.AsQueryable()groupnbynew{FirstLetter=n[0],Length=n.Length}我将字符串“Jon”添加到数组的末尾以获得实际分组,并得出以下结果:这正是我所期待的。然后,在LINQPad中,我转到同一查询的VB.NET版本:'Manuall

c# - Entity Framework : Efficiently grouping by month

我对此做了一些研究,到目前为止我发现的最好的方法是在整个数据集上使用Asenumerable,以便在对象的linq中而不是在数据库中进行过滤。我使用的是最新的EF。我的工作(但非常慢)代码是:vartrendData=fromdinExpenseItemsViewableDirect.AsEnumerable()groupdbynew{Period=d.Er_Approved_Date.Year.ToString()+"-"+d.Er_Approved_Date.Month.ToString("00")}intogselectnew{Period=g.Key.Period,Total=

c# - 为什么 C# LINQ 表达式必须以 Select 或 Group By 子句结尾,而在 VB.Net 中没有这样的限制

由于我的标题是不言自明的,我知道如何纠正它,但首先为什么会这样?场景我写了一个VB.Net代码DimlistAsList(OfString)=NewList(OfString)//CodetopopulatelistDimwherelinqAsIEnumerable(OfString)=FromsInlistWheres.StartsWith("A")这工作正常,没有错误但在C#中同样的逻辑失败了Listlist=newList();//CodetopopulatelistIEnumerablewherelinq=fromsinlistwheres.StartsWith("A");这给

C# 正则表达式 : Named Group Valid Characters?

什么是有效的组名?varre=newRegex(@"(?pattern)"); 最佳答案 简答允许的字符是[a-zA-Z0-9_]长答案根据Microsoftdocs:namemustnotcontainanypunctuationcharactersandcannotbeginwithanumber.不过说的不是很具体,还是看源码吧:sourcecodefortheclassSystem.Text.RegularExpressions.RegexParser向我们展示了允许的字符本质上是[a-zA-Z0-9_]。确切地说,在用于检

c# - LINQ TO 数据集 : Multiple group by on a data table

我正在使用Linqtodataset来查询数据表。如果我想对数据表的“Column1”执行分组,我使用以下查询vargroupQuery=fromtableinMyTable.AsEnumerable()grouptablebytable["Column1"]intogroupedTableselectnew{x=groupedTable.Key,y=groupedTable.Count()}现在我想对两列“Coulmn1”和“Column2”进行分组。谁能告诉我语法或提供一个链接来解释数据表上的多个分组依据??谢谢 最佳答案 您应

c# - 如何修复 'compiler error - cannot convert from method group to System.Delegate' ?

publicMainWindow(){CommandManager.AddExecutedHandler(this,ExecuteHandler);}voidExecuteHandler(objectsender,ExecutedRoutedEventArgse){}错误1​​参数2:无法从“方法组”转换为“System.Delegate” 最佳答案 我猜有多个具有不同签名的ExecuteHandler。只需将您的处理程序转换为您想要的版本:CommandManager.AddExecuteHandler(this,(Action)

c# - IEnumerable<TSource> Concat<TSource> 是否保留元素的顺序?

假设有两个列表A和B,因此A=(1,2,3)和B=(4,5,6)。A.Concat(B)会保留顺序以便结果为(1,2,3,4,5,6)吗? 最佳答案 是的。IEnumerable.Concat只需将一个列表附加到另一个列表的末尾,即可将两个列表变成一个列表。每个列表中的顺序将被保留。 关于c#-IEnumerableConcat是否保留元素的顺序?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/qu