Last active
January 18, 2017 21:09
-
-
Save kleberksms/c925fb4dfc019b2361ab840c9ea91ac0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyContext : DbContext | |
| { | |
| public MyContext(DbContextOptions<MyContext> options) :base(options) | |
| { } | |
| public DbSet<Obj1> Obj1s { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ObjRepository : IObjRepository | |
| { | |
| private readonly MyContext _context; | |
| public ObjRepository(MyContext context) | |
| { | |
| _context = context; | |
| } | |
| public IEnumerable<int> GetFooBar(List<int> lista) | |
| { | |
| var list = _context.Obj1.Where(p => lista.Contains(p.Field)) | |
| .Select(p => p.Id) | |
| .ToList(); | |
| return list; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Startup | |
| { | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.AddDbContext<MyContext>(options => | |
| options.UseMySQL(Configuration.GetConnectionString("MysqlConnection"))); | |
| services.AddMvc(); | |
| services.AddScoped<IObjRepository, ObjRepository>(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment