public static void SetRawModel(Type type, IMutableModel model, IShamanLogger logger)
        {
            void Log(string message)
            {
                logger.Log(typeof(ModelsCachedContainer), nameof(SetRawModel), message);
            }

            string MutableEntityTypeToString(IMutableEntityType mutableEntityType)
            {
                try
                {
                    var r = mutableEntityType.Relational();
                    return($"{r.Schema}.{r.TableName}");
                }
                catch (Exception e)
                {
                    logger.LogException(Guid.Parse("{22CC8890-B871-45BF-890E-9341B41183F6}"), e);
                    return("??");
                }
            }

            var value  = EfModelWrapper.FromModel(model);
            var result = Cache.TryAdd(type, value);

            Log(result ? "Success" : "Skipped");
        }
        private EfModelWrapper GetModelInternal()
        {
            var instance = TryCreateInstance(DbContextType);

            if (instance == null)
            {
                return(null);
            }
            var model = EfModelWrapper.FromModel(instance.Model);

            return(model);
        }
示例#3
0
        private static IReadOnlyDictionary <Type, string> GetTableNamesFromModel(EfModelWrapper model)
        {
            if (model == null)
            {
                return(null);
            }
            var result = new Dictionary <Type, string>();

            foreach (var entityType in model.EntityTypes)
            {
                result[entityType.ClrType] = entityType.TableName;
            }
            return(result);
        }
示例#4
0
        private static IReadOnlyDictionary <Type, string> GetTableNamesFromModel(EfModelWrapper model,
                                                                                 IShamanLogger logger)
        {
            if (model == null)
            {
                return(null);
            }
            var result = new Dictionary <Type, string>();

            foreach (var entityType in model.EntityTypes)
            {
                result[entityType.ClrType] = entityType.TableName;
                logger.Log(typeof(ModelInfo), nameof(GetTableNamesFromModel),
                           $"Table name for {entityType.ClrType.Name}: {entityType.TableName}");
            }
            return(result);
        }
        public static void SetRawModel(Type type, IMutableModel modelBuilderModel)
        {
            var value = EfModelWrapper.FromModel(modelBuilderModel);

            Cache.TryAdd(type, value);
        }