Exemple #1
0
        static EF7DataContext()
        {
            var t = typeof(TEntity);

            EntityType = EntityTypes.FirstOrDefault(x => x.Name == (t.Name.Substring(1)));
            ctxType    = ContextTypes.FirstOrDefault(x => x.BaseType != null && x.BaseType.Name.Contains("DbContext"));
            if (EntityType == null)
            {
                throw new InvalidOperationException("DataType Is not Found");
            }
            if (ctxType == null)
            {
                throw new InvalidOperationException("DBContext Is not Found");
            }
        }
Exemple #2
0
        static EntityViewDataContext()
        {
            var bt = typeof(TEntityView).GetInterfaces().FirstOrDefault(x => x.Name.Contains("IEntityView"));

            TEntity    = bt.GetGenericArguments().First();
            EntityType = EntityTypes.FirstOrDefault(x => x.Name == (TEntity.Name.Substring(1)));

            ViewType = EntityTypes.FirstOrDefault(x => x.Name == (typeof(TEntityView).Name.Substring(1)));
            ctxType  = ContextTypes.FirstOrDefault(x => x.BaseType != null && x.BaseType.Name.Contains("DbContext"));

            if (ViewType == null)
            {
                throw new InvalidOperationException("ViewType Is not Found");
            }
            if (ctxType == null)
            {
                throw new InvalidOperationException("DBContext Is not Found");
            }
        }