我添加了一个 RIA 域服务方法以从表中返回两个属性的简单 NameValuePair(并根据键值进行过滤)。
它编译得很好,但每次都炸毁而没有给出有用的错误。
我错过了什么?(可能很明显)
例如:
public IQueryable<NameValuePair> GetNameValues(int keyId)
{
// NOTE: I can breakpoint here and the correct keyId is passed
// it blows up on returning from this method
return from p in this.ObjectContext.NameTable
where p.KeyId == keyId
select new NameValuePair(p.NameValue, p.NameType);
}
简单的 NameValuePair代码:
public class NameValuePair
{
[Key]
public string Name { get; set; }
public string Value { get; set; }
public NameValuePair()
{
}
public NameValuePair( string name, string value)
{
this.Name = name;
this.Value = value;
}
}
更新:
我尝试在 NameValuePair 对象的静态列表上返回一个查询,并且效果很好(但没用)。