Snacks.Entity.Core is a .NET Core framework that aims to simplify the relationship between the database and the public-facing REST API.
Use the NuGet package manager to install the latest version of Snacks.Entity.Core
Install-Package Snacks.Entity.Core
using System;
using Snacks.Entity.Core;
public class StudentService : EntityServiceBase<StudentModel, MyDbContext>
{
public StudentService(
IServiceScopeFactory scopeFactory) : base(scopeFactory) { }
}
using System;
using Microsoft.Extensions.DependencyInjection;
using Snacks.Entity.Core;
public class StudentController : EntityControllerBase<StudentModel>
{
public StudentController(
IServiceProvider serviceProvider) : base(serviceProvider) { }
}
In your Startup.cs
file, add the entity services in the ConfigureServices method.
using Snacks.Entity.Core;
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<MyDbContext>();
services.AddEntityServices();
}
Your application should now allow you to query data RESTfully like api/students?grade[gte]=5&orderby[desc]=age&offset=5&limit=20
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT © Irla Software Solutions