public static StoreProperty ToStorePropertyMin(DesignColumn c) { var result = new StoreProperty { Name = c.Name, Type = c.Type, Pk = c.Pk, Fk = !string.IsNullOrWhiteSpace(c.Reference), Nullable = c.Nullable, AutoIncrement = c.Pk, }; return(result); }
public static StoreProperty ToStoreProperty(DesignSchema schema, DesignTable t, DesignColumn c) { var i = t.Columns.IndexOf(c); var result = new StoreProperty { Name = c.Name, Type = c.Type, Pk = c.Pk, Fk = !string.IsNullOrWhiteSpace(c.Reference), Nullable = c.Nullable, AutoIncrement = c.Pk, ForeignKeys = GetForeignKeysForColumn(schema, t, c), Order = i++ }; return(result); }
private static List <StoreForeignKey> GetForeignKeysForColumn(DesignSchema schema, DesignTable t, DesignColumn c) { if (!string.IsNullOrWhiteSpace(c.TableReference) && !string.IsNullOrWhiteSpace(c.ColumnReference)) { var type = schema.Tables.FirstOrDefault(t => t.Name == c.TableReference).Columns[0].Type; return((new StoreForeignKey[] { new StoreForeignKey { DefinitionName = c.TableReference, PropertyName = c.ColumnReference, Type = type } }).ToList()); } return(new List <StoreForeignKey>()); }