public string DesignShemaTypeToCSharp(StoreProperty p) { if (p.Pk && p.Type == "int") { //return "long"; return("int"); } string result; if (p.Fk) { result = DesignSchemaTypesMap[p.ForeignKeys.First().Type]; } else { if (DesignSchemaTypesMap.ContainsKey(p.Type)) { result = DesignSchemaTypesMap[p.Type]; } else { result = p.Type; } } if (result != "string" && p.Nullable) { result = result + "?"; } return(result); }
public StoreSchema ReadSchema(IStoreSchemaReaderParameters parameters) { var dr = parameters as EntityFrameworkStoreSchemaReaderParameters; if (dr == null) { throw new Exception($"EntityFrameworkStoreSchemaReader expects EntityFrameworkStoreSchemaReaderParameters."); } var schema = new StoreSchema { Definitions = new Dictionary <string, StoreDefinition>(), DbContextName = dr.DbContextType.FullName }; using (var db = GetDbContext(dr.DbContextType)) { var entities = db.Model.GetEntityTypes(); foreach (var entityMetadata in entities) { var def = new StoreDefinition { Properties = new Dictionary <string, StoreProperty>() }; def.Name = entityMetadata.ClrType.Name; schema.Definitions.Add(def.Name, def); var props = entityMetadata.GetProperties().ToList(); for (int i = 0; i < props.Count; i++) { var prop = props[i]; var storeProp = new StoreProperty { Name = prop.Name, Order = i, Type = GetTypeString(prop.ClrType), Pk = prop.IsPrimaryKey(), Fk = prop.IsForeignKey(), MaxLength = prop.GetMaxLength(), AutoIncrement = prop.ValueGenerated == ValueGenerated.OnAdd }; if (prop.IsForeignKey()) { var fks = prop.GetContainingForeignKeys(); storeProp.ForeignKeys = prop.GetContainingForeignKeys().Select(f => new StoreForeignKey { DefinitionName = f.PrincipalEntityType.ClrType.Name, PropertyName = f.PrincipalKey.Properties.First().Name, CompositePropertyNames = f.PrincipalKey.Properties.Select(p => p.Name).ToList() }).ToList(); } def.Properties.Add(storeProp.Name, storeProp); } } } return(schema); }
private string GetPropertyDataType(StoreProperty p) { if (p.Type == "reference" && p.Fk) { return(p.ForeignKeys[0].Type); } return(p.Type); }
private static string GetDesignForeignKey(StoreProperty c) { if (c.ForeignKeys.Any()) { var fk = c.ForeignKeys.First(); return($"{fk.DefinitionName}.{fk.PropertyName}"); } return(null); }
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); }
/// <summary> /// Get value from a store property /// </summary> /// <param name="prop">indicate the store property</param> /// <param name="propId">the expected property Id</param> /// <param name="defaultValue">default value</param> /// <param name="callerName">caller name of this method, such as [JobMonitorEntry.GetMinAndMax]. it is only used in the log</param> /// <returns>return property value if it exists, otherwise return default value</returns> internal static object GetStorePropertyValue(StoreProperty prop, PropertyId propId, object defaultValue, string callerName) { if (prop.Id == propId && prop.Value != null) { return(prop.Value); } else { TraceHelper.TraceEvent( TraceEventType.Error, "{0} Can't get valid value from store property {1}.", callerName, propId.Name); return(defaultValue); } }
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); }
public QuerySelectProperty(QueryFromTable fromTable, StoreProperty source) { FromTable = fromTable; StoreProperty = source; }
set => SetValue(StoreProperty, value);
set { SetValue(StoreProperty, value); OnPropertyChanged(); }
public EvalueStorageNG() { // Just init list Evalues = new List <Evalue>(); PropStore = new StoreProperty <Evalue>(); }
public QueryFromProperty(QuerySelectProperty source) { OriginalStoreProperty = new SubQueryStoreProperty(source); }
public QueryFromProperty(StoreProperty source) { OriginalStoreProperty = source; }
public QueryFromProperty(StoreProperty source) { StoreProperty = source; }