Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

LuEfDataAccess.cs 889B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using Luticate2.Utils.Dbo;
  3. using Microsoft.EntityFrameworkCore;
  4. using Microsoft.Extensions.Logging;
  5. namespace Luticate2.Utils.DataAccess
  6. {
  7. public class LuEfDataAccess<TModel, TDbo, TDbContext> : LuDataAccess
  8. where TModel : class
  9. where TDbo : class
  10. where TDbContext : DbContext, new()
  11. {
  12. protected readonly TDbContext Db;
  13. protected readonly DbSet<TModel> Table;
  14. protected LuEfDataAccess(TDbContext db, DbSet<TModel> table)
  15. {
  16. Db = db;
  17. Table = table;
  18. }
  19. public LuResult<T> Execute<T>(Func<TDbContext, DbSet<TModel>, LuResult<T>> func)
  20. {
  21. try
  22. {
  23. return func(Db, Table);
  24. }
  25. catch (Exception e)
  26. {
  27. return LuResult<T>.Error(LuStatus.DbError, e);
  28. }
  29. }
  30. }
  31. }