Skip to content

A graphQL like library to ease the pain of server side - database Query with projection for client side

Notifications You must be signed in to change notification settings

tadesamson/GetOption

Repository files navigation

GetOption

A graphQL like library to ease the pain of server side - database Query with projection for client side

Basic Usage

Sample 1

GetOption<User> userOption = new GetOption<User>();
userOption.SearchOption = new SearchOption<User>();
SearchExpression firstnameExp = new PropertySearchExpression() { Property = nameof(User.Firstname), Operator = "%", Value = "mat" };
SearchExpression dobExp = new PropertySearchExpression() { Property = nameof(User.DOB), Operator = ">", Value = "1999-01-17T10:30:40.808+00:00" };
userOption.SearchOption.Expression = new BinarySearchExpression<User>() { LeftSearch = firstnameExp, BinaryOperator = "&&", RightSearch = dobExp };
var users = await userRepository.GetEntitiesAsync(userOption);

Sample 2

var userIds= new List<string>(){"abc","xyz","kcf","mmt","gte"};
GetOption<User> userOption = new GetOption<User>();
userOption.SearchOption = new SearchOption<OrganizationSet>();
string userIdQuery = "";
userIds.ForEach(uid => userIdQuery += $"{nameof(User.Id)}={uid} ||");
userIdQuery = userIdQuery.Trim().Trim('|').Trim('|');
userOption.SearchOption = new SearchOption<User>();
userOption.SearchOption.Expression = SearchOption<User>.DeserializeSearchExpression(userIdQuery);
List<User> users = await userRepository.GetEntitiesAsync(userOption);

For information on the motivation, comparison with GraphQL and other uses such as for loading certain properties, for sorting, for pagination, see my developing Medium post.

About

A graphQL like library to ease the pain of server side - database Query with projection for client side

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages