예제 #1
0
 private void InitEntityMetaDataCache()
 {
     foreach (var entityType in EntityTypes)
     {
         EntityMetaDataCacheType.InitTypeHandler(entityType);
     }
 }
예제 #2
0
        public SmartSqlConfig Build()
        {
            if (Initialized)
            {
                return(SmartSqlConfig);
            }

            SmartSqlConfig = Parent.Build();

            var sqlGen = new CUDSqlGenerator(SmartSqlConfig);

            foreach (var entityType in _entityTypeList)
            {
                var scope = EntityMetaDataCacheType.GetScope(entityType);
                if (!SmartSqlConfig.SqlMaps.TryGetValue(scope, out SqlMap sqlMap))
                {
                    sqlMap = new SqlMap
                    {
                        Path               = entityType.AssemblyQualifiedName,
                        Scope              = scope,
                        SmartSqlConfig     = SmartSqlConfig,
                        Statements         = new Dictionary <string, Statement>(),
                        Caches             = new Dictionary <string, Configuration.Cache>(),
                        MultipleResultMaps = new Dictionary <string, MultipleResultMap>(),
                        ParameterMaps      = new Dictionary <string, ParameterMap>(),
                        ResultMaps         = new Dictionary <string, ResultMap>()
                    };
                    SmartSqlConfig.SqlMaps.Add(scope, sqlMap);
                }
                var result = sqlGen.Generate(sqlMap, entityType);
                foreach (var statement in result)
                {
                    if (sqlMap.Statements.ContainsKey(statement.Key))
                    {
                        _logger.LogDebug("{0} Exists, CUD module Skip this Statement. Continue", statement.Key);
                        continue;
                    }
                    sqlMap.Statements.Add(statement.Key, statement.Value);
                }
            }

            Initialized = true;
            return(SmartSqlConfig);
        }
예제 #3
0
    public void GetTableName()
    {
        var tableName = EntityMetaDataCacheType.GetTableName(typeof(AllPrimitive));

        Assert.Equal("T_AllPrimitive", tableName);
    }
예제 #4
0
 public GeneratorParams(SqlMap map, Type entityType)
 {
     Map         = map;
     _entityType = EntityMetaDataCacheType.MakeGenericType(entityType);
 }