public void TestInitialize()
        {
            var options = new DbContextOptionsBuilder <RugbyUnionContext>().UseInMemoryDatabase("RubgyUnionManagementDatabase").UseLazyLoadingProxies().Options;

            _context = new RugbyUnionContext(options);
            _context.Database.EnsureCreated();
        }
        public static DbSet <Model> GetSet <Model>(this RugbyUnionContext context) where Model : class, IDbEntity <Model>
        {
            var type = typeof(Model);
            var set  = context
                       .GetType()
                       .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                       .SingleOrDefault(x => x.GetCustomAttribute <DbSetAttribute>() != null && x.GetCustomAttribute <DbSetAttribute>().ModelType == type);

            if (set == null)
            {
                throw new Exception($"Unable to find property with type DbSet<{type.Name}> in {context.GetType().Name}.");
            }

            var value = set.GetValue(context) as DbSet <Model>;

            return(value);
        }
 public CrudService(RugbyUnionContext context)
 {
     _context = context;
 }
Example #4
0
 public TeamService(RugbyUnionContext context)
 {
     _context = context;
 }
 public PlayerService(RugbyUnionContext context)
 {
     _context = context;
 }
 public StadiumService(RugbyUnionContext context)
 {
     _context = context;
 }