예제 #1
0
        public ApiEntityTypeConfiguration <TEntityType> Entity <TEntityType>()
            where TEntityType : class
        {
            Type entityType = typeof(TEntityType);
            ApiEntityTypeConfiguration entityTypeConfig;

            if (!this.entityTypeConfigs.TryGetValue(entityType, out entityTypeConfig))
            {
                EntityType dbEntityType;

                if (!this.dbEntityTypes.TryGetValue(entityType, out dbEntityType))
                {
                    throw new Exception(string.Format("There is no entity {0} in context {1}.",
                                                      entityType, contextName));
                }

                entityTypeConfig = new ApiEntityTypeConfiguration <TEntityType>(contextName, dbEntityType);

                this.entityTypeConfigs.Add(entityType, entityTypeConfig);
            }

            return((ApiEntityTypeConfiguration <TEntityType>)entityTypeConfig);
        }
예제 #2
0
 internal bool TryGetEntityTypeConfig(Type type, out ApiEntityTypeConfiguration entityTypeConfig)
 {
     return(this.entityTypeConfigs.TryGetValue(type, out entityTypeConfig));
 }