private EntityModel GetEmptyEntity(string entityName) { var entity = new EntityModel(entityName); var propertiesTypes = Client.GetPropertiesTypes(entityName); foreach (var(colName, colType) in propertiesTypes) { if (!Enum.TryParse(colType, true, out SqlDbType sqlDataType)) { continue; } var columnProperty = new EntityProperty { Name = colName, Type = sqlDataType }; entity.Add(columnProperty); } var allReferences = Client.GetAllReferences(entity.EntityName); foreach (var prop in entity) { var referenceEntity = allReferences.Where(x => x.Key == prop.Name) .Select(x => x.Value).FirstOrDefault(); if (referenceEntity == default) { continue; } prop.ReferenceEntity = referenceEntity; } return(entity); }
public bool SetAllValues(EntityModel entity) { bool allSucceded = true; foreach (var column in entity) { if (Options.CustomValues.Any(x => x.Key == $"{entity.EntityName}.{column.Name}")) { column.Value = Options.CustomValues.First(x => x.Key == $"{entity.EntityName}.{column.Name}").Value; } else { var generator = GetSqlTypeGenerator(column); column.Value = generator.GetValue(column); if (string.IsNullOrEmpty(column.Value)) { allSucceded = false; } } } return(allSucceded); }