views:

1404

answers:

1

Is it possible to pass a collection of objects to a RIA Data Service query? I have no issues sending an Entity, an Int or an array of primitive types, but as soon as i declare a method like this

public void GetLessonsConflicts(Lesson[] lessons)
{
}

i get a compilation error

" Operation named 'GetLessonsConflicts' does not conform to the required signature. Parameter types must be an entity type or one of the predefined serializable types"

I am just trying to do some validation on the server side before i save the data. I've tried List, IEnumerable etc.

Thanks

+3  A: 

I think the problem is actually the lack of a return value. As I understand it, you can identify DomainOperations by convention or by attribute. You're not showing an attribute so RIA will be trying to match it by convention.

For example, by convention, an insert method must:

  • have Insert, Add or Create as the method name prefix, e.g. InsertEmployee
  • match the signature public void name(Entity e);

a query method must:

  • be public
  • return IEnumerable, IQueryable or T (where T is an entity).

a custom domain operation must

  • be public
  • return void
  • have an Entity as the first parameter.

Or you can use Attributes such as [Insert],[Delete],[Update],[Query],[Custom]. From my docs, all the attributes do is remove the requirement for the name convention - it's not clear from them, to me, what the [Query] and [Custom] attributes achieve.

As well as DomainOperations, you can define ServiceOperations (using the [ServiceOperation] attribute) and InvokeOperations.

This article might help (although I think it's a bit out of date).

serialhobbyist
Great article! Answers many questions i had. Thanks
Vitalik