private static bool AreSameMetadata(MetadataModel source, MetadataModel target) { if (source == null && target == null) { return(true); } if (source == null || target == null || source.Count != target.Count) { return(false); } if (source.Any(entity => target.Count(c => c.Key == entity.Key) != 1)) { return(false); } return(source.All(sourceData => { var sourceDataItems = sourceData.Value; var targetDataItems = target[sourceData.Key]; return sourceDataItems.Count == targetDataItems.Count && sourceDataItems.All(sourceDataItem => targetDataItems.Count(targetDataItem => AreSameDataItems(sourceDataItem, targetDataItem)) == 1); })); }
public void Add(MetadataModel metadata) { _dbContext.RemoveRange(_dbContext.Query <MetadataCategory>().ToArray()); if (metadata.Any()) { _dbContext.AddRange(_mapper.Map <IEnumerable <MetadataCategory> >(metadata).ToArray()); } }