Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bonelol/JsonToQueryable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonToQueryable

Parse JSON string to expressions that used for querying in EntityFramework.Core 5.0

For example:

{
	"query": {
		"Name": "$contains 'Default'"
	},
	"include": {
		"Children": {
			"query": {
				"Year": "= 2020"
			}
		},
		"AnotherChildren": {}
	},
	"type": "ParentType",
	"page": 1,
	"pageSize": 25
}

will be convert to

dbContext.Parent.Include(p.Children.Where(c => c.Year == 2020))
                .Include(p.AnotherChildren)
                .Where(p=>p.Name.Contains("Default"))
                .Skip(page * pageSize)
                .Take(pageSize);

Support Where, Include, ThenInclude, Take, Skip

var query = Context.CreateQuery(queryString, new List<Type>() { typeof(Parent) }).Cast<Parent>();
return query.ToList();

About

Parse JSON string to expressions that used for querying in EntityFramework.Core

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages