如何通过 lightswitch 使用 RIA 服务的自定义类型?
我有一个使用 RIA 服务传递到 lightswitch 的服务类。服务类使用自定义类型而不是本机灯开关或 SQL 类型。
public class MyService : DomainService
{
[Query(IsDefault = true)]
public IQueryable<MyRecord> GetMyRecordData()
{
return ...
}
}
public class MyRecord
{
[Key]
public int Id {get; set;}
public string Text {get;set;}
public MyCustomType Custom {get;set;}
}
public struct MyCustomType
{
public MyCustomType (int val1, int val2) : this ()
{
Val1 = val1;
Val2 = val2;
}
public int Val1 {get; private set;}
public int Val2 {get; private set;}
}
如何让灯开关使用这种自定义类型进行显示?
I have a service class that is passed to lightswitch using RIA services. The service class uses a custom type instead of native lightswitch or SQL types.
public class MyService : DomainService
{
[Query(IsDefault = true)]
public IQueryable<MyRecord> GetMyRecordData()
{
return ...
}
}
public class MyRecord
{
[Key]
public int Id {get; set;}
public string Text {get;set;}
public MyCustomType Custom {get;set;}
}
public struct MyCustomType
{
public MyCustomType (int val1, int val2) : this ()
{
Val1 = val1;
Val2 = val2;
}
public int Val1 {get; private set;}
public int Val2 {get; private set;}
}
How to have lightswitch use this custom type for its display ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自定义类型不支持作为实体成员,除非它们实现 IList 接口。即使在 IList 实现的情况下,也不允许您提供复杂类型的列表,而只能提供简单的 .NET 类型。因此,无法将 MyCustomType 的实例作为受支持的实体成员传递。
不幸的是,Microsoft 已将 RIA 规范下线,但您仍然可以找到复制此处。有关此限制的说明,请参阅第 4.11 节。
Custom types are not supported as entity members unless they implement the IList interface. Even in the case of an IList implementation, you would not be allowed to provide a list of complex types, just simple .NET types. So there's no way to pass an instance of MyCustomType as a supported entity member.
Unfortunately Microsoft has taken the RIA spec offline, but you can still find a copy here. See section 4.11 for an explanation of this limitation.