public EntityModel Copy() { EntityModel em = new EntityModel(EntityName); foreach (var prop in this) { var entityProp = new EntityProperty() { Name = prop.Name, ReferenceEntity = prop.ReferenceEntity, Type = prop.Type, Value = prop.Value }; em.Add(entityProp); } return(em); }
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); }