azure local storage table 自定义字段为空

azure local storage table custom fields are null

我正在尝试创建一个通用插入方法,我从抽象 TableEntity class.

生成一个 class
    class STCompany : TableEntity {
        string Abbrev;
        string Name;
        string NavName;

        public STCompany(
            string partitionKey, string rowKey, DateTime timeStamp,
            string abbrev, string name, string navName
        )
        {
            PartitionKey = partitionKey;
            RowKey = rowKey;
            Timestamp = timeStamp;
            Abbrev = abbrev;
            Name = name;
            NavName = navName;
        }

    }

尝试在此静态中创建通用插入方法class(请参阅代码块底部的插入任务)

    public static class lclStorage
    {
        private static string paramsConstring = __paramsConstring;
        private static CloudStorageAccount storageAcc;
        private static CloudTableClient tblclient;
        private static CloudTable get_params_table (string table_name){
            if(storageAcc == null) storageAcc = CloudStorageAccount.Parse(paramsConstring);  
            if(tblclient == null) tblclient = storageAcc.CreateCloudTableClient(new TableClientConfiguration());
            return tblclient.GetTableReference(table_name);
        }


        public static class cloudTables{
            public static CloudTable AccessUsersShareholders = get_params_table("AccessUsersShareholders");
            public static CloudTable CompanyPropertyMapping = get_params_table("CompanyPropertyMapping");
            public static CloudTable STCompanies = get_params_table("STCompanies");
            public static CloudTable STdepartments = get_params_table("STdepartments");
        }

        public static async Task<(int statusCode, string response, bool success)> Insert(CloudTable p_tbl, TableEntity te)  
        {  
            TableOperation insertOperation = TableOperation.InsertOrMerge(te);  
            TableResult result = await p_tbl.ExecuteAsync(insertOperation);  

            Console.WriteLine("Record Added");  
            return (
                result.HttpStatusCode, 
                (result.HttpStatusCode == 204) ? "Record added" : "Failed to add record", 
                result.HttpStatusCode == 204);  
        }  
        
    }

然后在我的主程序中 运行 Insert

      var result = await lclStorage.Insert( 
          lclStorage.cloudTables.STCompanies,
          new STCompany( "STCompanies", "TE3", DateTime.Now, "TE3", "test", "nav__test")
      );
      Console.WriteLine($"{result.response} __ {result.success}");

TableResult result中字段显示正确

但在我的 Azure table 字段 Abbrev、Name 和 NavName 中设置为空。 这是因为我在插入函数中将 TableEntity 声明为类型而不是 STCompany 还是我做错了什么?

因此TableEntityclass中的变量Abbrev,Name,NavName必须是public.

    class STCompany : TableEntity {
            public string Abbrev { get; set; }
            public string Name { get; set; }
            public string NavName { get; set; }

        public STCompany(
            string partitionKey, string rowKey,
            string abbrev, string name, string navName
        )
        {
            PartitionKey = partitionKey;
            RowKey = rowKey;
            Abbrev = abbrev;
            Name = name;
            NavName = navName;
        }

    }