dotnet-dynamic-linq/PoweredSoft.DynamicLinq.Test/GroupingTests.cs

77 lines
2.1 KiB
C#
Raw Normal View History

2018-03-08 21:18:43 -05:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2018-03-09 00:22:12 -05:00
using PoweredSoft.DynamicLinq;
2018-03-08 21:18:43 -05:00
namespace PoweredSoft.DynamicLinq.Test
{
internal class TestStructure
{
public long ClientId { get; set; }
public decimal B { get; set; }
}
2018-03-08 21:18:43 -05:00
[TestClass]
public class GroupingTests
{
[TestMethod]
public void WantedSyntax()
2018-03-09 00:22:12 -05:00
{/*
2018-03-08 21:18:43 -05:00
var regularSyntax = TestData.Sales
2018-03-08 22:59:18 -05:00
.GroupBy(t => t.ClientId);
var dynamicSyntax = TestData.Sales
.AsQueryable()
.GroupBy("ClientId");
2018-03-09 00:22:12 -05:00
2018-03-08 22:59:18 -05:00
var regularSyntax2 = TestData.Sales
.GroupBy(t => new
2018-03-08 21:18:43 -05:00
{
2018-03-08 22:59:18 -05:00
t.ClientId,
2018-03-09 00:22:12 -05:00
B = t.NetSales
});*/
2018-03-08 22:59:18 -05:00
var dynamicSyntax2 = TestData.Sales
.AsQueryable()
2018-03-09 00:22:12 -05:00
.GroupBy(t => t.Path("ClientId").Path("NetSales", "B"));
2018-03-08 22:59:18 -05:00
var dynamicSyntax3 = TestData.Sales
.AsQueryable()
.GroupBy(t => t.UseType(typeof(TestStructure)).Path("ClientId").Path("NetSales", "B"));
2018-03-08 21:18:43 -05:00
/*
2018-03-08 22:59:18 -05:00
.Select(t => new
{
TheClientId = t.Key,
Count = t.Count(),
CountClientId = t.Count(t2 => t2.ClientId > 1),
LongCount = t.LongCount(),
NetSales = t.Sum(t2 => t2.NetSales),
TaxAverage = t.Average(t2 => t2.Tax),
Sales = t.ToList()
});*/
/*
.Select(t =>
{
t.PropertyFromKey("TheClientId", "ClientId");
t.Count("Count");
// don't have to implement right away.
t.Count("CountClientId", "ClientId", ConditionOperators.GreaterThan, 1);
t.LongCount("LongCount");
t.Sum("NetSales");
t.Average("TaxAverage", "Tax");
t.ToList("Sales");
});*/
2018-03-08 21:18:43 -05:00
}
}
}