Exemplo n.º 1
0
        public static void BeginNamespace(this Csdl.Schema schema, CSharpCodeWriter codeWriter, NamespaceFor nsFor)
        {
            codeWriter.Namespace(schema.Namespace);

            if ((nsFor & NamespaceFor.PrimitiveTypes) != 0)
            {
                codeWriter.Using("System");
            }
            if ((nsFor & NamespaceFor.CollectionTypes) != 0)
            {
                codeWriter.Using("System.Collections.Generic");
            }
            if ((nsFor & NamespaceFor.Annotations) != 0)
            {
                codeWriter.Using("System.ComponentModel.DataAnnotations");
                codeWriter.Using("System.ComponentModel.DataAnnotations.Schema");
            }
            if ((nsFor & NamespaceFor.DbContext) != 0)
            {
                codeWriter.Using("Microsoft.EntityFrameworkCore");
            }
            codeWriter.NewLine();
        }
Exemplo n.º 2
0
 public static void WriteComplexType(this ComplexType type,
                                     Csdl.Schema schema, Configuration config, CSharpCodeWriter codeWriter)
 {
     codeWriter.Type(config.ComplexMetaType, type.Name, null, Modifiers.Partial);
     foreach (var prop in type.Properties.OrEmpty())
     {
         prop.WriteOut(null, schema, codeWriter);
         codeWriter.NewLine();
     }
     codeWriter.BlockEnd();
 }
Exemplo n.º 3
0
 public static void WriteEntityContainer(this EntityContainer container,
                                         Csdl.Schema schema, Configuration config, CSharpCodeWriter codeWriter)
 {
     config.LazyLoading = config.LazyLoading ?? container.LazyLoadingEnabled;
     container.WriteClass(schema, codeWriter);
 }
Exemplo n.º 4
0
 public static void WriteEnum(this EnumType type, CSharpCodeWriter codeWriter)
 {
     codeWriter.Enum(type.Name,
                     type.Members.Select(m => (m.Name, m.Value)).ToArray(),
                     type.UnderlyingType);
 }