从类内部的方法中获取单个字符串值

时间:2018-11-13 11:10:03

标签: c#

我想获取APPname的值,该值由称为-GetProductResearchCredidentials()的方法返回并存储在像波纹管这样的字符串变量中-

string myVal = //让我知道如何从该方法中获取值

从方法返回的我的模型:

public partial class EbayAPIProductResearch
    {
        public int EbayAPIID { get; set; }
        public string APPname { get; set; }
        public string DevName { get; set; }
        public string CertName { get; set; }
        public string Token { get; set; }
        public Nullable<bool> CallLimitExpired { get; set; }
        public Nullable<System.DateTime> DateOfRenewal { get; set; }
        public Nullable<System.DateTime> DateOfFindItemAdvanced { get; set; }
        public Nullable<bool> FindItemExpired { get; set; }
    }

我的方法:

public class EbayAPIData
    {
        public static Models.EbayAPIProductResearch GetProductResearchCredidentials()
        {
            using (var ctx = new db_zikanalyticsProductionEntities())
            {
                var apis = ctx.EbayAPIProductResearch.ToList();
                foreach (var item in apis)
                {
                    var cestTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time"));
                    if (cestTime > item.DateOfRenewal)
                    {
                        var apiitem = ctx.EbayAPIProductResearch.FirstOrDefault(x => x.EbayAPIID == item.EbayAPIID);
                        apiitem.CallLimitExpired = false;
                        ctx.SaveChanges();
                        return apiitem;
                    }
                }
                return null;
            }
        }
    }

1 个答案:

答案 0 :(得分:1)

因此,如果您的商品类似

var item = EbayAPIData.GetProductResearchCredidentials();

您可以通过以下方式访问其属性

item.APPName