Beispiel #1
0
 /// <summary>
 /// Sets up the fields needed to store the data for lazy loading
 /// </summary>
 /// <param name="TypeBuilder"></param>
 private void SetupFields(Reflection.Emit.TypeBuilder TypeBuilder)
 {
     if (ClassMappings.ContainsKey(TypeBuilder.BaseClass))
     {
         foreach (IMapping Mapping in ClassMappings[TypeBuilder.BaseClass])
         {
             foreach (IProperty Property in Mapping.Properties)
             {
                 if (Property is IManyToOne || Property is IMap)
                 {
                     if (Fields.FirstOrDefault(x => x.Name == Property.DerivedFieldName) == null)
                         Fields.Add(TypeBuilder.CreateField(Property.DerivedFieldName, Property.Type));
                 }
                 else if (Property is IIEnumerableManyToOne || Property is IManyToMany)
                 {
                     if (Fields.FirstOrDefault(x => x.Name == Property.DerivedFieldName) == null)
                         Fields.Add(TypeBuilder.CreateField(Property.DerivedFieldName, typeof(IEnumerable<>).MakeGenericType(Property.Type)));
                 }
                 else if (Property is IListManyToOne || Property is IListManyToMany)
                 {
                     if (Fields.FirstOrDefault(x => x.Name == Property.DerivedFieldName) == null)
                         Fields.Add(TypeBuilder.CreateField(Property.DerivedFieldName, typeof(List<>).MakeGenericType(Property.Type)));
                 }
             }
         }
     }
 }