public static CommandEntity FromProperties(IReadOnlyDictionary <string, object> properties, RepositoryEntityMetadata metadata) { properties.GuardAgainstNull(nameof(properties)); metadata.GuardAgainstNull(nameof(metadata)); if (!properties.ContainsKey(nameof(Id)) || properties[nameof(Id)] == null) { throw new InvalidOperationException( "Unable to create a new CommandEntity. There is no 'Id' property in this collection of values."); } var result = new CommandEntity(properties[nameof(Id)].ToString()); foreach (var property in properties) { var propertyType = metadata.GetPropertyType(property.Key, false); if (propertyType != null) { result.Add(property.Key, property.Value, propertyType); } } return(result); }
public static QueryEntity FromProperties(IReadOnlyDictionary <string, object> properties, RepositoryEntityMetadata metadata) { properties.GuardAgainstNull(nameof(properties)); metadata.GuardAgainstNull(nameof(metadata)); var dataEntity = new QueryEntity(); foreach (var pair in properties) { var propertyType = metadata.GetPropertyType(pair.Key, false); if (propertyType != null) { dataEntity.Add(pair.Key, pair.Value, propertyType); } } return(dataEntity); }