从类中调用视图中的方法属性?

时间:2016-11-28 16:55:52

标签: c# html asp.net-mvc

在课程PCSS.Common.Configuration.ConfigurationFunctions中,我需要在视图中调用方法属性var qe = new QueryExpression("pcs_configurationitem");

var qe = new QueryExpression(" pcs_configurationitem");是一个字符串方法

下面是字符串中var qe的代码,我需要在视图中调用pcs_configurationitem。

public static string GetString(string key, IOrganizationService service)
{
    var qe = new QueryExpression("pcs_configurationitem"); //want this in view
    qe.Criteria.AddCondition(new ConditionExpression("pcs_name", ConditionOperator.Equal, key));
    qe.Criteria.AddCondition(new ConditionExpression("pcs_valuetype", ConditionOperator.Equal, (int)ConfigItemType.String));
    qe.Criteria.AddCondition(new ConditionExpression("pcs_stringvalue", ConditionOperator.NotNull));
    qe.ColumnSet = new ColumnSet(new string[] { "pcs_stringvalue" });
    var results = service.RetrieveMultiple(qe);
    if (results.Entities.Count == 0) throw new Exception("No value of this type found for key " + key);
    return (results[0].GetAttributeValue<string>("pcs_stringvalue"));
}

我尝试做以下的事情,在我的视野中调用它。

<span title="Feedback is not suppored more than @ConfigurationFunctions.("pcs_configurationitem") days after closing the enquiry.">`</span>`

但是这不起作用,请告知。

1 个答案:

答案 0 :(得分:0)

您可以在页面顶部放置一些代码:

@model MyModel
@{
  var qe = new QueryExpression("pcs_configurationitem"); 
}

然后在你的标记中:

<span title="Feedback is not suppored more than @qe days after closing the enquiry."></span>

您可能需要在顶部添加@using指令,以引用QueryExpression的相应命名空间。