views:

28

answers:

1

I would like a method on my in my domain service similar to:

public SystemState GetSystemStatus()
{
    return new SystemStatus
    {
        InterestingStatusValue1 = 1223,
        OtherInterstingStatusValue = "abc",
    }
}

That doesn't work. Nothing is auto-generated for the Silverlight client app. Howerver if I make this an IQueryable method, then I get something generated on the client. I'll get a SystemStates property and a Query method on the context object.

Is there no way to make this a simple WCF call? I suppose I could a WCF Silverlight Enabled service to my RIA Web site, and then setting a Service Reference (that can't be right?) (and why can't I see the Services Reference in the Silverlight app?)

On first blush it seems that RIA services forces a very data-centric/easy CRUD which is great for table editors, but not so much for LOB applications that go behind drag on a datagrid and you're done.

+1  A: 

Hi Ralph,

You can return just one entity using an attribute (assuming that SystemState is your entity):

Ex:

[Query(IsComposable = false)]
public SystemState GetSystemStatus()
{
    return new SystemStatus
    {
        InterestingStatusValue1 = 1223,
        OtherInterstingStatusValue = "abc",
    }
}

Remember that this is still a query and Ria Services will generate a method in your DomainContext like:

EntityQuery<SystemState> GetSystemStatusQuery()

Use it like a normal EntityQuery, but keep in mind that you can't perform query operations (sorting or filtering) on the returned object.

If you want to execute an operation on server, try using the [Invoke] attribute. Ex:

[Invoke]
public SystemState GetSystemStatus()
{
    return new SystemStatus
    {
        InterestingStatusValue1 = 1223,
        OtherInterstingStatusValue = "abc",
    }
}

I don't know how complex your return type can be, but I guess if it can be serialized, it will work (not sure).

andrecarlucci
EDIT: check more details about the DomainService here: http://msdn.microsoft.com/en-us/library/ee707373(VS.91).aspx
andrecarlucci