public Property Add(Property newProperty) { try { var typeName = _context.Types.Find(newProperty.TypeId)?.Name; var sql = SqlOptions.GenerateInsertIntoScript(typeName, newProperty); _context.Database.ExecuteSqlCommand(sql); var property = new SqlHandler(_context).GetTypePropertiesByName(typeName) .FirstOrDefault(a => a.Key == newProperty.Key && a.TypeId == newProperty.TypeId && a.EntityId == newProperty.EntityId && a.Value == newProperty.Value); if (property.IsComplex) { SetDisplayComplexValue(property); } return(property); } catch (Exception e) { Console.WriteLine(e); return(null); } }
public void SetDisplayComplexValue(Property property) { var complexPropertyTypeName = property.Key.Substring(8); var propertyName = GetAttributeValue(complexPropertyTypeName, "display"); var propertyValue = GetByPropertyName(propertyName, complexPropertyTypeName, int.Parse(property.Value)) .Value; property.DisplayComplexValue = propertyValue; }