/// <summary> /// Initializes a new instance of the <see cref="T:System.Object" /> class. /// </summary> public EntityRelationship(EntityRelationSide from, EntityRelationSide to, bool willCascadeOnDelete, EntityInfo manyToManyTable = null) { From = from; To = to; WillCascadeOnDelete = willCascadeOnDelete; ManyToManyTable = manyToManyTable; }
public static NavigationPropertyEntityInfo Many(string name, EntityInfo otherSideEntity) { var itemType = otherSideEntity.GetTypeUsage(); var type = typeof (ICollection<>).ToGenericUsageInfo(itemType); var initializationType = typeof (HashSet<>).ToGenericUsageInfo(itemType); return new NavigationPropertyEntityInfo(name, type, initializationType); }
internal ModelInfo(EntityInfo entity, ITable<TableContent, ColumnContent> table, List<PropertyModelInfo> properties) { IsPartial = true; Entity = entity; Table = table; ModelProperties = properties; Name = Entity.Name + "Model"; Description = string.Format("Model for <see cref=\"{0}\"/> entity", entity.Name); }
internal static void AddExplicitProperty(PropertyInfo property, TypeUsageInfo iintervalfields, EntityInfo entity) { if (property.Type.IsNullable) { return; } var prop = new PropertyInfo(property.Name, TypeUsageInfo.CreateNullable(property.Type), new PropertyInvokerInfo(string.Format("return {0};", property.Name)), new PropertyInvokerInfo(string.Format("if(value.HasValue){0} = value.Value; else throw new ArgumentNullException(\"value\");", property.Name))); prop.ExplicitInterface = iintervalfields; entity.AddProperty(prop); }
internal static void AddChangeDateProperty(PropertyInfo createDateProperty, PropertyInfo changeDateProperty, TypeUsageInfo iintervalfields, EntityInfo entity) { var getter = string.Format("return {0};", changeDateProperty.Name); if(changeDateProperty.Type.IsNullable) { var createPropertyGetter = createDateProperty.Name; if (createDateProperty.Type.IsNullable) { createPropertyGetter = createDateProperty.Name + " ?? DateTime.Now"; } getter = string.Format("if({0}.HasValue) return {0}.Value; else return {1};", changeDateProperty.Name, createPropertyGetter); } var prop = new PropertyInfo(changeDateProperty.Name, (typeof(DateTime)).ToUsageInfo(), new PropertyInvokerInfo(getter), new PropertyInvokerInfo(string.Format("{0} = value;", changeDateProperty.Name))); prop.ExplicitInterface = iintervalfields; entity.AddProperty(prop); }
internal static void AddHasTitleProperty(TypeUsageInfo ihastitle, EntityInfo entity, TableContent tableContent) { var prop = new PropertyInfo("EntityTitle", new FieldInfo("EntityTitle", (typeof(string)).ToUsageInfo()), new PropertyInvokerInfo(string.Format("return {0}.ToString();", tableContent.TitleFieldName)), null); prop.ExplicitInterface = ihastitle; entity.AddProperty(prop); }
public static NavigationPropertyEntityInfo One(string name, EntityInfo otherSideEntity) { var type = otherSideEntity.GetTypeUsage(); return new NavigationPropertyEntityInfo(name, type, null); }
public static NavigationPropertyEntityInfo One(string name, EntityInfo otherSideEntity) { var type = otherSideEntity.GetTypeUsage(); return(new NavigationPropertyEntityInfo(name, type, null)); }