Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace PlanCompilerTests
{
using System.Data.Entity;
using System.Linq;
using AdvancedPatternsModel;
using Xunit;
/// <summary>
/// Tests for anonymous types in Linq queries.
/// </summary>
public class AnonymousTypeTests : FunctionalTestBase
{
#region Infrastructure/setup
#endregion
#region Tests for anonymous types produced after a join statement
[Fact]
private void AnonymousType_join_selecting_one_member()
{
using (var context = new AdvancedPatternsMasterContext())
{
var query = context.WorkOrders.Select(wo => wo.EmployeeId).Join(
context.Employees.Select(e => e.EmployeeId), a => a, b => b, (a, b) => new
{
a
});
var sql = query.ToString();
Assert.True(sql != null);
}
}
[Fact]
private void AnonymousType_join_selecting_two_members()
{
using (var context = new AdvancedPatternsMasterContext())
{
var query = context.WorkOrders.Select(wo => wo.EmployeeId).Join(
context.Employees.Select(e => e.EmployeeId), a => a, b => b, (a, b) => new
{
a,
b
});
var sql = query.ToString();
Assert.True(sql != null);
}
}
[Fact]
private void AnonymousType_join_selecting_one_member_and_one_constant()
{
using (var context = new AdvancedPatternsMasterContext())
{
var query = context.WorkOrders.Select(wo => wo.EmployeeId).Join(
context.Employees.Select(e => e.EmployeeId), a => a, b => b, (a, b) => new
{
a,
c = 1
});
var sql = query.ToString();
Assert.True(sql != null);
}
}
[Fact]
private void AnonymousType_join_selecting_two_members_and_one_constant()
{
using (var context = new AdvancedPatternsMasterContext())
{
var query = context.WorkOrders.Select(wo => wo.EmployeeId).Join(
context.Employees.Select(e => e.EmployeeId), a => a, b => b, (a, b) => new
{
a,
b,
c = 1
});
var sql = query.ToString();
Assert.True(sql != null);
}
}
#endregion
}
}

View File

@@ -0,0 +1,73 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace PlanCompilerTests
{
using System.Data.Entity;
using System.Linq;
using AdvancedPatternsModel;
using Xunit;
/// <summary>
/// Tests for GroupBy statements in Linq queries.
/// </summary>
public class LinqGroupByTests : FunctionalTestBase
{
#region Infrastructure/setup
#endregion
#region Tests for GroupBy that trigger an aggregate pushdown
[Fact]
private void GroupBy_aggregate_pushdown_single_key()
{
using (var context = new AdvancedPatternsMasterContext())
{
var groupByQuery = from workOrder in context.WorkOrders
group new
{
workOrder.WorkOrderId,
workOrder.Details
} by workOrder.EmployeeId
into ordersByEmployeeGroup
select new
{
EmployeeId = ordersByEmployeeGroup.Key,
OrderCount = ordersByEmployeeGroup.Count(),
MaxOrderId = ordersByEmployeeGroup.Max(o => o.WorkOrderId)
};
var sql = groupByQuery.ToString();
Assert.True(sql != null && sql.ToUpper().Contains("GROUP BY"));
}
}
// Dev11 448362
[Fact]
private void GroupBy_aggregate_pushdown_translates_NewRecordOp()
{
using (var context = new AdvancedPatternsMasterContext())
{
var groupByNewQuery = from workOrder in context.WorkOrders
group new
{
workOrder.WorkOrderId,
workOrder.Details
} by new
{
workOrder.EmployeeId
}
into ordersByEmployeeGroup
select new
{
ordersByEmployeeGroup.Key.EmployeeId,
OrderCount = ordersByEmployeeGroup.Count(),
MaxOrderId = ordersByEmployeeGroup.Max(o => o.WorkOrderId)
};
var sql = groupByNewQuery.ToString();
Assert.True(sql != null && sql.ToUpper().Contains("GROUP BY"));
}
}
#endregion
}
}