如果我有以下集合
IEnumerable<ProviderOrganisation> listOfProviders
public class ProviderOrganisation
{
public virtual string Code { get; set; }
public virtual string Description { get; set; }
public virtual int SortOrder { get; set; }
public virtual bool IsDefault { get; set; }
public virtual DateTime EffectiveStartDate { get; set; }
public virtual DateTime? EffectiveEndDate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我该如何编写 LINQ 来生成仅包含代码的集合?
所以,只是代码列表:
List<string> listOfCodes
Run Code Online (Sandbox Code Playgroud)
谢谢
我想查询一行输出左表中的Id和连接表中的描述.
架构:
person
---------
id (int)
role
-------------
id (int)
description (varchar(100))
personrole
-------------
personid (int)
roleid (int)
Run Code Online (Sandbox Code Playgroud)
示例数据:
person
------------
id
1
2
role
------------
id description
1 user
2 admininstrator
3 tester
personrole
-------------
personid roleid
1 1
2 1
2 2
2 3
Run Code Online (Sandbox Code Playgroud)
所以,我希望输出为:
PersonId Roles
1 user
2 user;administrator;tester
Run Code Online (Sandbox Code Playgroud) 我正在使用SQL Server 2008
如果我有这样的表:
Code Value
-----------------------
4 240
4 299
4 210
2 NULL
2 3
6 30
6 80
6 10
4 240
2 30
Run Code Online (Sandbox Code Playgroud)
如何通过Code列找到中位数AND组?要获得这样的结果集:
Code Median
-----------------------
4 240
2 16.5
6 30
Run Code Online (Sandbox Code Playgroud)
我真的很喜欢这个中位数的解决方案,但不幸的是它不包括Group By:https: //stackoverflow.com/a/2026609/106227