dtretyakov / WindowsAzure

.NET library aimed at managing and querying entities from Windows Azure Storage. It can be used as LINQ to Azure Tables.
MIT License
64 stars 27 forks source link

Validation to enforce entities to have both Partition key and Row key is incomplete #66

Closed artyomabrahamyan closed 4 months ago

artyomabrahamyan commented 4 years ago

Whenever inserting a new entity into Microsoft.WindowsAzure.Storage.Table.CloudTable it is mandatory to have both partition key and row key defined.

However in EntityTypeMap's AutoMap method the for check check whether entity's PartitionKey and RowKey completely defined performed as follows:

if (!_nameChanges.ContainsValue(PartitionKeyPropertyName) && !_nameChanges.ContainsValue(RowKeyPropertyName)) { var message = string.Format(Resources.EntityTypeDataMissingKey, _entityType); throw new InvalidOperationException(message); }

This check misses the case when user defines one of the keys and omits the other.