Adds extensions to Linq to offer dynamic queryables.
Go to file
2018-02-12 21:31:49 -06:00
PoweredSoft.DynamicLinq collection handling. 2018-02-12 21:27:09 -06:00
PoweredSoft.DynamicLinq.Dal Add project files. 2018-02-11 19:55:29 -06:00
PoweredSoft.DynamicLinq.Test collection handling. 2018-02-12 21:27:09 -06:00
.gitattributes Add .gitignore and .gitattributes. 2018-02-11 19:55:28 -06:00
.gitignore Add .gitignore and .gitattributes. 2018-02-11 19:55:28 -06:00
PoweredSoft.DynamicLinq.sln Add project files. 2018-02-11 19:55:29 -06:00
README.md documentation. 2018-02-12 21:31:49 -06:00

DynamicLinq

Adds extensions to Linq to offer dynamic queryables.

Samples

Complex Query

query = query.Query(q =>
{
    q.Compare("AuthorId", ConditionOperators.Equal, 1);
    q.And(sq =>
    {
        sq.Compare("Content", ConditionOperators.Equal, "World");
        sq.Or("Title", ConditionOperators.Contains, 3);
    });
});

###Simple Query

query.Where("FirstName", ConditionOperators.Equal, "David");

###Simple Sorting

query = query.OrderByDescending("AuthorId");
query = query.ThenBy("Id");

###Collection Filtering You don't have to Worry about it. The libary will do it for you.

var query = authors.AsQueryable();
query = query.Query(qb =>
{
    qb.NullChecking();
	// you can specify here which collection handling you wish to use Any and All is supported for now.
    qb.And("Posts.Comments.Email", ConditionOperators.Equal, "john.doe@me.com", collectionHandling: QueryCollectionHandling.Any);
});

###Null Checking automaticly (practical for in memory dynamic queries)

var query = authors.AsQueryable();
query = query.Query(qb =>
{
    qb.NullChecking();
    qb.And("Posts.Comments.Email", ConditionOperators.Equal, "john.doe@me.com", collectionHandling: QueryCollectionHandling.Any);
});

###Using Query Builder

// subject.
var posts = new List<Post>()
{
    new Post { Id = 1, AuthorId = 1, Title = "Hello 1", Content = "World" },
    new Post { Id = 2, AuthorId = 1, Title = "Hello 2", Content = "World" },
    new Post { Id = 3, AuthorId = 2, Title = "Hello 3", Content = "World" },
};

// the query.
var query = posts.AsQueryable();
var queryBuilder = new QueryBuilder<Post>(query);

queryBuilder.Compare("AuthorId", ConditionOperators.Equal, 1);
queryBuilder.And(subQuery =>
{
    subQuery.Compare("Content", ConditionOperators.Equal, "World");
    subQuery.Or("Title", ConditionOperators.Contains, 3);
});

query = queryBuilder.Build();