本文整理汇总了C#中IQueryable.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.Intersect方法的具体用法?C# IQueryable.Intersect怎么用?C# IQueryable.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQueryable
的用法示例。
在下文中一共展示了IQueryable.Intersect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeOfCareIntersect
private IQueryable<Facility> TypeOfCareIntersect(PSS2012DataContext context, IQueryable<Facility> query, IEnumerable<Offering> offerings, bool wideSearch)
{
if (offerings.Count() > 0)
{
if (wideSearch)
{
//wider search - includes any of the input offerings
var ofg = context.Offerings.Where(Offering.ContainsOfferings(offerings))
.Join(context.FacilityOfferings, oid => oid.OfferingGuid, iid => iid.OfferingGuid,
(oid, iid) => iid)
.Join(query, oid => oid.FacilityGuid, iid => iid.FacilityGuid, (oid, iid) => iid);
//
query = query.Intersect(ofg);
}
else
{
// get offering guid list as queryable to avoid not supported exception
var offeringsAsQueryable = context.Offerings.Where(Offering.ContainsOfferings(offerings)).Select(s => s.OfferingGuid);
// group by guid and intersect with offerings
var facilityOfferings = context.FacilityOfferings
.GroupBy(g => g.FacilityGuid)
.Select(s => new { Fguid = s.Key, Fos = s.Select(ss => ss.OfferingGuid).Intersect(offeringsAsQueryable) })
.Where(w => w.Fos.Count() == offeringsAsQueryable.Count());
query = query.Join(facilityOfferings, oid => oid.FacilityGuid, iid => iid.Fguid, (oid, iid) => oid);
}
}
return query.OrderBy(f => f.FacilityName);
}
示例2: if
private static IQueryable<试题外部信息表> 取分类下的试题(string 分类集合字符串, IQueryable<试题外部信息表> 查询条件, LoveKaoExamEntities db)
{
IQueryable<试题外部信息表> querySort = db.试题外部信息表;
string[] sortList = 分类集合字符串.Split(",".ToCharArray());
List<string> listSort = 分类.分类处理(sortList.ToList());
//分类个数为1
if (listSort.Count == 1)
{
List<string> listAllSort = 分类.得到分类及子分类名称集合(listSort[0]);
querySort = from outside in db.试题外部信息表
join sort in db.所属分类表 on outside.ID equals sort.相关信息ID
where listAllSort.Contains(sort.分类名)
select outside;
querySort = 查询条件.Intersect(querySort);
}
//取并集
else if (listSort.Count > 1)
{
List<string> listAllSort = 分类.得到分类及子分类名称集合(listSort[0]);
querySort = from outside in db.试题外部信息表
join sort in db.所属分类表 on outside.ID equals sort.相关信息ID
where listAllSort.Contains(sort.分类名)
select outside;
for (int i = 1; i < listSort.Count; i++)
{
List<string> listNextAllSort = 分类.得到分类及子分类名称集合(listSort[i]);
IQueryable<试题外部信息表> queryNextSort = from outside in db.试题外部信息表
join sort in db.所属分类表 on outside.ID equals sort.相关信息ID
where listNextAllSort.Contains(sort.分类名)
select outside;
querySort = querySort.Union(queryNextSort);
}
querySort = 查询条件.Intersect(querySort);
}
return querySort;
}