描述:查询顾客覆盖的国家
查询句法:
var 过滤相同项 = (from c in ctx.Customers orderby c.Country select c.Country).Distinct(); |
描述:查询城市是A打头和城市包含A的顾客并按照顾客名字排序
查询句法:
var 连接并且过滤相同项 = (from c in ctx.Customers where c.City.Contains("A") select c).Union (from c in ctx.Customers where c.ContactName.StartsWith("A") select c).OrderBy(c => c.ContactName); |
描述:查询城市是A打头和城市包含A的顾客并按照顾客名字排序,相同的顾客信息不会过滤
查询句法:
var 连接并且不过滤相同项 = (from c in ctx.Customers where c.City.Contains("A") select c).Concat (from c in ctx.Customers where c.ContactName.StartsWith("A") select c).OrderBy(c => c.ContactName); |
取项相交
描述:查询城市是 A 打头的顾客和城市包含 A 的顾客的交集,并按照顾客名字排序
查询句法:
var 取相交项 = (from c in ctx.Customers where c.City.Contains("A") select c).Intersect (from c in ctx.Customers where c.ContactName.StartsWith("A") select c).OrderBy(c => c.ContactName); |
排除相交项
描述:查询城市包含A的顾客并从中删除城市以A开头的顾客,并按照顾客名字排序
查询句法:
var 排除相交项 = (from c in ctx.Customers where c.City.Contains("A") select c).Except (from c in ctx.Customers where c.ContactName.StartsWith("A") select c).OrderBy(c => c.ContactName); |