123456789101112131415161718192021222324252627282930313233 |
- using System;
- using Luticate2.Utils.Dbo;
- using Microsoft.EntityFrameworkCore;
-
- namespace Luticate2.Utils.DataAccess
- {
- public abstract class LuEfDataAccess<TModel, TDbContext> : LuDataAccess
- where TModel : class
- where TDbContext : DbContext
- {
- protected readonly TDbContext Db;
-
- protected readonly DbSet<TModel> Table;
-
- protected LuEfDataAccess(TDbContext db, DbSet<TModel> table)
- {
- Db = db;
- Table = table;
- }
-
- public LuResult<T> Execute<T>(Func<LuResult<T>> func)
- {
- try
- {
- return func();
- }
- catch (Exception e)
- {
- return LuResult<T>.Error(LuStatus.DbError, e);
- }
- }
- }
- }
|