0

我有这个返回Setting类型的方法,我想检查第四列的值 -

当前代码:

public Setting TestSettings(Example _example, String type)
{
    var results = _example.GetExample("Testing");
    return results;
}

设定模型

string Description { get; set; }
Guid? Guid1 { get; set; }
Guid? Guid2 { get; set; }
string Key { get; set; }
string Value { get; set; }

获取示例

public Setting GetExample(string key)
        {
            using (var db = MyDataContext.StoredProcs)
            {
                return db.GetExample<Setting>(key, _curGuid1, _curGuid2, SettingExtensions.SettingFactory());
            }
        }

我想访问设置结果中的(键)来验证它是否等于类型。

4

1 回答 1

0

您已经知道密钥,它正在传递给GetExample函数:

var results = _example.GetExample("Testing"); // <--- here

否则,它应该像从结果中获取属性一样简单:

public Setting TestSettings(Example _example, String type)
{
    var results = _example.GetExample("Testing");

    if (results.Key == type)
    {
        // whatever you need to do here
    }

    return results;
}
于 2013-08-06T10:08:46.810 回答