Azure表存储实体行/主键作为现有属性的属性
我已经从EntityFramework迁移了实体。 我不想重写某些属性并将其转换为字符串Azure表存储实体行/主键作为现有属性的属性,azure,azure-storage,Azure,Azure Storage,我已经从EntityFramework迁移了实体。 我不想重写某些属性并将其转换为字符串 public class User : TableEntity, ITableStorageEntity<int, Guid> { [RowKey] public Guid ID { get; set; } [PartitionKey] public int LanguageID { get; set; } 公共类用户:TableEntity、I
public class User : TableEntity, ITableStorageEntity<int, Guid>
{
[RowKey]
public Guid ID { get; set; }
[PartitionKey]
public int LanguageID { get; set; }
公共类用户:TableEntity、ITableStorageEntity
{
[罗凯]
公共Guid ID{get;set;}
[分区键]
public int LanguageID{get;set;}
有可能吗?我不希望重写ReadEntity/WriteEntity。因为您的类已经基于TableEntity,您可能希望尝试使用“new”关键字重写/替换TableEntity的行键和分区键属性
public class User : TableEntity
{
[IgnoreProperty]
public Guid ID { get; set; }
[IgnoreProperty]
public int LanguageID { get; set; }
public new string PartitionKey { get { return ID.ToString(); } set { ID = Guid.Parse(value); } }
public new string RowKey { get { return LanguageID.ToString(); } set { LanguageID = int.Parse(value); } }
}
我不太喜欢“新”修饰符。我认为这是一种非面向对象的方法 我建议如下
public class ConsumerApplicationEntity : TableEntity
{
public ConsumerApplicationEntity(string applicationKey, string applicationSecret)
: base(applicationKey, applicationSecret)
{
}
[IgnoreProperty]
public string ApplicationKey
{
get
{
return this.PartitionKey;
}
set
{
this.PartitionKey = value;
}
}
[IgnoreProperty]
public string ApplicationSecret
{
get
{
return this.RowKey;
}
set
{
this.RowKey = value;
}
}
}
您不想重写属性或读/写方法的任何原因?