我目前正在使用 WCF RIA 域服务类来生成字典对象列表。
[Invoke]
public IEnumerable<IDictionary> GenerateData()
{
List<IDictionary> newList = new List<IDictionary>();
for (var i = 0; i < 10; i++)
{
var dict = new Dictionary<string, object>();
dict["ID"] = Guid.NewGuid();
dict["Name"] = "Name_" + i;
dict["Index"] = i;
newList.Add(dict);
}
return newList;
}
我想将此列表传递给 Silverlight:
DomainContext _myContext = new DomainContext();
InvokeOperation<IEnumerable<IDictionary>> loadop4 = this._myContext.GenerateData();
loadop4.Completed += new System.EventHandler(loadop4_callback);
void loadop4_callback(Object sender, System.EventArgs e)
{
InvokeOperation<IEnumerable<IDictionary>> iop = sender as InvokeOperation<IEnumerable<IDictionary>>;
//... do stuff with IOP
}
但它在 VS2010 中给了我这个错误:
Error 1 Operation named 'GenerateData' does not conform to the required signature. Return types must be an entity or complex type, a collection of entities or complex types, or one of the predefined serializable types.
我该如何解决?我认为 Silverlight 支持字典列表