mirror of https://github.com/icsharpcode/ILSpy.git
13 changed files with 18049 additions and 40 deletions
@ -0,0 +1,184 @@
@@ -0,0 +1,184 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
||||
{ |
||||
public class QueryExpressions |
||||
{ |
||||
public class Customer |
||||
{ |
||||
public int CustomerID; |
||||
public IEnumerable<Order> Orders; |
||||
public string Name; |
||||
public string Country; |
||||
public string City; |
||||
} |
||||
|
||||
public class Order |
||||
{ |
||||
public int OrderID; |
||||
public DateTime OrderDate; |
||||
public Customer Customer; |
||||
public int CustomerID; |
||||
public decimal Total; |
||||
public IEnumerable<OrderDetail> Details; |
||||
} |
||||
|
||||
public class OrderDetail |
||||
{ |
||||
public decimal UnitPrice; |
||||
public int Quantity; |
||||
} |
||||
|
||||
public IEnumerable<Customer> customers; |
||||
public IEnumerable<Order> orders; |
||||
|
||||
public object MultipleWhere() |
||||
{ |
||||
return from c in this.customers |
||||
where c.Orders.Count() > 10 |
||||
where c.Country == "DE" |
||||
select c; |
||||
} |
||||
|
||||
public object SelectManyFollowedBySelect() |
||||
{ |
||||
return from c in this.customers |
||||
from o in c.Orders |
||||
select new { |
||||
c.Name, |
||||
o.OrderID, |
||||
o.Total |
||||
}; |
||||
} |
||||
|
||||
public object SelectManyFollowedByOrderBy() |
||||
{ |
||||
return from c in this.customers |
||||
from o in c.Orders |
||||
orderby o.Total descending |
||||
select new { |
||||
c.Name, |
||||
o.OrderID, |
||||
o.Total |
||||
}; |
||||
} |
||||
|
||||
public object MultipleSelectManyFollowedBySelect() |
||||
{ |
||||
return from c in this.customers |
||||
from o in c.Orders |
||||
from d in o.Details |
||||
select new { |
||||
c.Name, |
||||
o.OrderID, |
||||
d.Quantity |
||||
}; |
||||
} |
||||
|
||||
public object MultipleSelectManyFollowedByLet() |
||||
{ |
||||
return from c in this.customers |
||||
from o in c.Orders |
||||
from d in o.Details |
||||
let x = d.Quantity * d.UnitPrice |
||||
select new { |
||||
c.Name, |
||||
o.OrderID, |
||||
x |
||||
}; |
||||
} |
||||
|
||||
public object FromLetWhereSelect() |
||||
{ |
||||
return from o in this.orders |
||||
let t = o.Details.Sum((Func<OrderDetail, decimal>)((OrderDetail d) => d.UnitPrice * d.Quantity)) |
||||
where t >= 1000m |
||||
select new { |
||||
OrderID = o.OrderID, |
||||
Total = t |
||||
}; |
||||
} |
||||
|
||||
public object MultipleLet() |
||||
{ |
||||
return from a in this.customers |
||||
let b = a.Country |
||||
let c = a.Name |
||||
select b + c; |
||||
} |
||||
|
||||
public object Join() |
||||
{ |
||||
return from c in this.customers |
||||
join o in this.orders on c.CustomerID equals o.CustomerID |
||||
select new { |
||||
c.Name, |
||||
o.OrderDate, |
||||
o.Total |
||||
}; |
||||
} |
||||
|
||||
public object JoinInto() |
||||
{ |
||||
return from c in this.customers |
||||
join o in this.orders on c.CustomerID equals o.CustomerID into co |
||||
let n = co.Count() |
||||
// should be n >= 10
|
||||
where !(n < 10) |
||||
select new { |
||||
Name = c.Name, |
||||
OrderCount = n |
||||
}; |
||||
} |
||||
|
||||
public object OrderBy() |
||||
{ |
||||
return from o in this.orders |
||||
orderby o.Customer.Name, o.Total descending |
||||
select o; |
||||
} |
||||
|
||||
public object GroupBy() |
||||
{ |
||||
return from c in this.customers |
||||
group c.Name by c.Country; |
||||
} |
||||
|
||||
public object ExplicitType() |
||||
{ |
||||
return from Customer c in this.customers |
||||
where c.City == "London" |
||||
select c; |
||||
} |
||||
|
||||
public object QueryContinuation() |
||||
{ |
||||
return from c in this.customers |
||||
group c by c.Country into g |
||||
select new { |
||||
Country = g.Key, |
||||
CustCount = g.Count() |
||||
}; |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue