Reputation: 2169
I have an azure table that has the following schema:
public class Village : TableServiceEntity
{
public Village(string districtName, string villageName)
{
PartitionKey = districtName.ToLower().Trim();
RowKey = villageName.ToLower().Trim();
DistrictName = districtName;
VillageName = villageName;
}
public string DistrictName {get;set;}
public string VillageName {get;set;}
}
The district name and village name are the partition and row key respectively. I want this key to be case insensitive. That is if the user gives the following values then both should represent the same entity:
That is
DistrictName = "TVM"; VillageName = "CHEN";
and
DistrictName = "Tvm"; VillageName = "Chen";
both the above values represent the same entity. I need to store the partition and row key in case insensitive way. Is this the right approach ?
Upvotes: 2
Views: 2524
Reputation: 60153
Yes, this seems like the right approach.
You might want to use ToUpperInvariant
instead of ToLower
. I think uppercase has fewer edge cases, and using the invariant culture may save you from more edge cases. (I know very little about this, so look it up instead of believing me.)
Upvotes: 5