Releases: PoweredSoft/DynamicLinq
Support for .Trim() .ToLower() and any methods on typeof(string)
You can now use .ToLower() .Trim() or any methods
[TestMethod]
public void EqualLowerCase()
{
// subject.
var authors = new List<Author>()
{
new Author { Id = long.MaxValue, FirstName = "David", LastName = "Lebee" }
};
// the query.
var query = authors.AsQueryable();
// simple where.
var newQuery = query.Where("FirstName.ToLower()", ConditionOperators.Equal, "david");
// must match.
Assert.IsTrue(newQuery.Any(), "Must have at least one author that matches");
}
Inherited Enumerable Support
The code can now support to create expressions with class inheriting IEnumerable.
class Foo
{
}
class ListOfFoo : List<Foo>
{
}
[TestMethod]
public void TestInheritanceOfListAsGenericEnumerableType()
{
var shouldBeTrue = QueryableHelpers.IsGenericEnumerable(typeof(ListOfFoo));
Assert.IsTrue(shouldBeTrue);
var type = QueryableHelpers.GetTypeOfEnumerable(typeof(ListOfFoo), true);
Assert.IsTrue(type == typeof(Foo));
}
Allows
public class MockPerson
{
public string Name { get; set; }
public MockListOfPhone Phones { get; set; }
}
public class MockPhone
{
public string Number { get; set; }
}
public class MockListOfPhone : List<MockPhone>
{
}
[TestMethod]
public void TestSelectWithInheritedList()
{
var list = new List<MockPerson>()
{
new MockPerson
{
Name = "David Lebee",
Phones = new MockListOfPhone
{
new MockPhone
{
Number = "0000000000"
}
}
},
new MockPerson
{
Name = "Yubing Liang",
Phones = new MockListOfPhone
{
new MockPhone
{
Number = "1111111111"
}
}
}
};
var names = list.AsQueryable()
.Where(t => t.Equal("Phones.Number", "1111111111"))
.Select(t =>
{
t.Path("Name");
t.FirstOrDefault("Phones.Number", "Number", SelectCollectionHandling.Flatten);
})
.ToDynamicClassList();
Assert.IsTrue(names.Count() == 1);
var firstPerson = names.First();
Assert.AreEqual("Yubing Liang", firstPerson.GetDynamicPropertyValue<string>("Name"));
Assert.AreEqual("1111111111", firstPerson.GetDynamicPropertyValue<string>("Number"));
}
Support of LessThan and GreaterThan for strings
New release with support of Support of LessThan and GreaterThan for strings.
[TestMethod]
public void TestLessAndGreaterThan()
{
var context = GetCoreContext(nameof(TestWhereAnd)); //EF Core
//or new BlogContext(testConnectionString); in EF
SeedForTests(context);
var query = context.Authors.Query(q => q.LessThan("FirstName", "Mario"));
var first = query.FirstOrDefault();
Assert.AreEqual(first?.FirstName, "David");
query = context.Authors.Query(q => q.GreaterThan("FirstName", "Mario"));
first = query.FirstOrDefault();
Assert.AreEqual(first?.FirstName, "Some");
}
Thank you @boris612 for this nice collaboration.
For more information look at the pull request: #8
EFCore 3.0 & EF 6.3
Merge pull request #7 from PoweredSoft/feature/ef63-and-efcore3-alpha Feature/ef63 and efcore3 alpha
NotContains and Negate
Added ConditionalOperators.NotContains and Negate to be able to negate any ConditionalOperators.
Special thanks to
@Jon-Galloway
Added support of path for groups
Added support of path to groups for following select types.
ToList
First
FirstOrDefault
Last
LastOrDefault
New stuff :)
Added support of more complex grouping paths, and null checking is supported 👍
Adding support of more aggregate types for grouped selects.
- Min
- Max
- First
- Last
- FirstOrDefault
- LastOrDefault
Count and Long Count support
Added the possibility to do a Count and LongCount on IQueryable without having the need to cast to IQueryable