开发者

How to use a custom type from RIA services with lightswitch?

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开发者_Python百科;}
    public int Val2 {get; private set;}
}

How to have lightswitch use this custom type for its display ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜