private Property(Column column, string type, bool isReferenceType, string name, EntityConfig referenceEntityConfig) { this.Column = column; this.ReferenceEntityConfig = referenceEntityConfig; this.Type = type; this.IsReferenceType = isReferenceType; this.Name = name; this.VariableName = NameProvider.GetVariableName(name); }
private static string GetCreator(string className, IEnumerable<Property> properties) { var buffer = new StringBuilder(); var args = new StringBuilder(); var index = 0; foreach (var property in properties) { if (buffer.Length > 0) { buffer.AppendLine(); } if (args.Length > 0) { args.Append(@","); args.Append(@" "); } var variableName = property.VariableName; buffer.Append(@"var"); buffer.Append(@" "); buffer.Append(variableName); buffer.Append(@" = "); var referenceEntityConfig = property.ReferenceEntityConfig; if (referenceEntityConfig != null) { buffer.Append(NameProvider.GetVariableName(referenceEntityConfig.ClassPluralName)); buffer.Append(@"["); } ReadDbValue(buffer, property.Column, index++); if (referenceEntityConfig != null) { buffer.Append(@"]"); } buffer.Append(@";"); args.Append(variableName); } buffer.AppendLine(); buffer.AppendLine(); buffer.Append(@"return"); buffer.Append(@" "); buffer.Append(@"new"); buffer.Append(@" "); buffer.Append(className); buffer.Append(@"("); buffer.Append(args); buffer.Append(@")"); buffer.Append(@";"); return buffer.ToString(); }
public Property(Column column, KeyValuePair<string, bool> type, string name, EntityConfig referenceEntityConfig, bool isCaption = false, bool generateField = true) { this.Column = column; this.ReferenceEntityConfig = referenceEntityConfig; this.Type = type.Key; this.IsReferenceType = type.Value; this.Name = name; this.VariableName = NameProvider.GetVariableName(name); this.IsCaption = isCaption; this.GenerateField = generateField; }
private static string GetDictionariesVariables(IEnumerable<Property> properties) { var buffer = new StringBuilder(); foreach (var property in properties) { var referenceEntityConfig = property.ReferenceEntityConfig; if (referenceEntityConfig != null) { if (buffer.Length > 0) { buffer.AppendLine(); } buffer.Append(@"var"); buffer.Append(@" "); buffer.Append(NameProvider.GetVariableName(referenceEntityConfig.ClassPluralName)); buffer.Append(@" = "); buffer.Append(@"cache.GetData"); buffer.Append(@"<"); buffer.Append(referenceEntityConfig.ClassName); buffer.Append(@">"); buffer.Append(@"("); buffer.Append(@"dbContext"); buffer.Append(@")"); buffer.Append(@";"); } } if (buffer.Length > 0) { buffer.Insert(0, Environment.NewLine); buffer.AppendLine(); } return buffer.ToString(); }