コード例 #1
0
        public string GetTableDefinitionsCodeForEntityTypes(
            ITableMetaInfoBuilder tmiBldr,
            IEnumerable <Type> types,
            TDCodeGenerator codeGenOps = null,
            bool withNamespace         = true)
        {
            if (types == null)
            {
                return(null);
            }

            Type[] arr = types.ToArray();

            var codes = new List <string>(arr.Length);

            for (int i = 0; i < arr.Length; i++)
            {
                Type   t    = arr[i];
                string code = tmiBldr.GetTableDefinitionCode(
                    t,
                    codeGenOps,
                    withNamespace: false);                     // must NOT have ns!
                codes.Add(code);
            }

            if (!withNamespace)
            {
                return(codes.JoinToString("\r\n"));
            }

            return(codeGenOps.WrapTableDefinitionsCodeInOuterNamespaceAndUsings(codes));
        }
コード例 #2
0
        public static string WriteTableDefinitionsCodeForAllDbSets(
            this DbContext[] dbContexts,
            TDCodeGenerator options,
            string pathTDsCSFile,
            string pathTDsOldCommentedOutCSFile      = null,
            int maxLinesToSaveOldCommentedOutVersion = 10_000)
        {
            if (options == null)
            {
                options = new TDCodeGenerator();
            }

            var tdCodes = new List <string>(dbContexts.Length);

            for (int i = 0; i < dbContexts.Length; i++)
            {
                string tdCode = GetTableDefinitionsCodeForAllDbSets(dbContexts[i], options, withNamespace: false);
                tdCodes.Add(tdCode);
            }

            string finalResult = options.WriteNewTableDefinitionsCode(
                tdCodes,
                pathTDsCSFile,
                pathTDsOldCommentedOutCSFile,
                maxLinesToSaveOldCommentedOutVersion);

            return(finalResult);
        }
コード例 #3
0
 public static string GetTableDefinitionsCodeForAllDbSets(
     this ITableMetaInfoBuilder tmiBldr,
     TDCodeGenerator codeGenOps = null,
     bool withNamespace         = true)
 => GetTableDefinitionsCodeForEntityTypes(
     tmiBldr,
     tmiBldr.GetEntityTypes(),
     codeGenOps,
     withNamespace);
コード例 #4
0
        public static string GetTableDefinitionsCodeForAllDbSets(
            this DbContext dbContext,
            TDCodeGenerator options = null,
            bool withNamespace      = true)
        {
            ITableMetaInfoBuilder tableMeta = dbContext.GetTableMetaInfoBuilder();
            string code = tableMeta.GetTableDefinitionsCodeForAllDbSets(options, withNamespace);

            return(code);
        }
コード例 #5
0
        public static string GetTableDefinitionsCodeForAllDbSets(
            this DbContext[] dbContexts,
            TDCodeGenerator options = null)
        {
            var tdCodes = new List <string>(dbContexts.Length);

            if (options == null)
            {
                options = new TDCodeGenerator();
            }

            for (int i = 0; i < dbContexts.Length; i++)
            {
                string tdCode = GetTableDefinitionsCodeForAllDbSets(dbContexts[i], options, withNamespace: false);
                tdCodes.Add(tdCode);
            }

            string code = options.WrapTableDefinitionsCodeInOuterNamespaceAndUsings(tdCodes);

            return(code);
        }
コード例 #6
0
 public static string GetTableDefinitionCode(
     this ITableMetaInfo tinfo,
     TDCodeGenerator codeGenOps = null,
     bool withNamespace         = true)
 => codeGenOps.E().GetTableDefinitionCode(tinfo, withNamespace);
コード例 #7
0
 public static string GetTableDefinitionCode(
     this ITableMetaInfoBuilder tmiBldr,
     Type type,
     TDCodeGenerator codeGenOps = null,
     bool withNamespace         = true)
 => codeGenOps.E().GetTableDefinitionCode(tmiBldr, type, withNamespace);
コード例 #8
0
 public static string GetTableMetaInfoCode(
     this ITableMetaInfo tmi)
 => TDCodeGenerator.GetTableMetaInfoCodeStatic(tmi);
コード例 #9
0
 public static string GetTableDefinitionsCodeForEntityTypes(
     this ITableMetaInfoBuilder tmiBldr,
     IEnumerable <Type> types,
     TDCodeGenerator codeGenOps = null,
     bool withNamespace         = true)
 => codeGenOps.E().GetTableDefinitionsCodeForEntityTypes(tmiBldr, types, codeGenOps, withNamespace);