示例#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));
        }
 public static string GetTableDefinitionsCodeForAllDbSets(
     this ITableMetaInfoBuilder tmiBldr,
     TDCodeGenerator codeGenOps = null,
     bool withNamespace         = true)
 => GetTableDefinitionsCodeForEntityTypes(
     tmiBldr,
     tmiBldr.GetEntityTypes(),
     codeGenOps,
     withNamespace);
        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);
        }
示例#4
0
        public string GetTableDefinitionCode(
            ITableMetaInfoBuilder tmiBldr,
            Type type,
            bool withNamespace = true)
        {
            TableMetaInfo tinfo = tmiBldr.GetTableMetaInfo(type);

            string code = GetStronglyTypedTableDefinitionCode(tinfo);

            if (withNamespace)
            {
                code = WrapTableDefinitionsCodeInOuterNamespaceAndUsings(new string[] { code });
            }

            return(code);
        }
 public static string GetTableDefinitionCode(
     this ITableMetaInfoBuilder tmiBldr,
     Type type,
     TDCodeGenerator codeGenOps = null,
     bool withNamespace         = true)
 => codeGenOps.E().GetTableDefinitionCode(tmiBldr, type, withNamespace);
 public static string GetTableDefinitionsCodeForEntityTypes(
     this ITableMetaInfoBuilder tmiBldr,
     IEnumerable <Type> types,
     TDCodeGenerator codeGenOps = null,
     bool withNamespace         = true)
 => codeGenOps.E().GetTableDefinitionsCodeForEntityTypes(tmiBldr, types, codeGenOps, withNamespace);