从azure表读取行时为空值
我试图从azure存储表中获取所有行,但当我显示它们时,除了 PartitionKey和RowKey为null或0。我是否遗漏了什么,或者我是否做错了什么,导致无法正确读取所有值 这是我用来获取所有数据的代码从azure表读取行时为空值,azure,azure-tablequery,Azure,Azure Tablequery,我试图从azure存储表中获取所有行,但当我显示它们时,除了 PartitionKey和RowKey为null或0。我是否遗漏了什么,或者我是否做错了什么,导致无法正确读取所有值 这是我用来获取所有数据的代码 List<Employe> employeList = new List<Employe>(); TableQuery<Employe> query = new TableQuery<Employe>(); employeList =
List<Employe> employeList = new List<Employe>();
TableQuery<Employe> query = new TableQuery<Employe>();
employeList = table.ExecuteQuery(query).ToList();
我自己没有测试过,但我很确定这是适用的: 使用TableQuery及其内置反序列化程序时,它使用无参数构造函数
public Employe()
创建新的空对象。然后它尝试查找匹配的属性,但不查找它们的名称。但是,由于所有属性的名称都与表存储中的值不同,因此不会设置任何属性
因此,或者重命名您的属性以匹配您的存储(例如将
public string prenume
重命名为public string prename
),或者在您的属性上使用注释,例如。我想出来了,我的azure表中的列名需要与我的参数名相同。谢谢
class Employe:TableEntity
{
public string prenume { get; set; }
public string functie { get; set; }
public int salar_baza { get; set; }
public int retineri { get; set; }
public int spor { get; set; }
public int total_brut { get; set; }
public int brut_impozabil { get; set; }
public int impozit { get; set; }
public int cas { get; set; }
public int cass { get; set; }
public int virat_card { get; set; }
public int premii_brute { get; set; }
public Employe()
{
}
public Employe(string nr_crt, string name,string prename,string function, int salarBaza,int retinere,int sporuri,int premiu_burt)
{
PartitionKey = nr_crt;
RowKey = name;
this.prenume = prename;
this.functie = function;
this.salar_baza = salarBaza;
this.retineri = retinere;
this.spor = sporuri;
this.premii_brute = premiu_burt;
this.total_brut = salarBaza+(salarBaza*(sporuri/100))+premiu_burt;
this.cas = (25/100)*total_brut;
this.cass = (10/100)*total_brut;
this.brut_impozabil = total_brut-cas-cass;
this.impozit = (10/100)*brut_impozabil;
this.virat_card =total_brut-impozit-cas-cass-retinere;
}
}