2011-09-27 61 views
0

我有一个使用RIA服务传递给lightswitch的服务类。服务类使用自定义类型而不是本机lightswitch或SQL类型。如何通过lightswitch使用RIA服务中的自定义类型?

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;} 
} 

如何让lightswitch使用此自定义类型进行显示?

回答

1

定制类型不支持作为实体成员,除非它们实现IList接口。即使在IList实现的情况下,也不允许您提供复杂类型的列表,只是简单的.NET类型。因此无法将MyCustomType的实例作为受支持的实体成员传递。

不幸的是微软已经脱离了RIA规范,但您仍然可以使用find a copy here。有关此限制的解释,请参阅第4.11节。

相关问题