Search code examples
c#silverlightsilverlight-4.0riadomain-service-class

Custom RIA Domain Service not based on an ADO.NET entity


All of my data can be accessed only through a COM object created like so:

Interaction.CreateObject("MyObject.Application","RemoteServer");

I have a bunch of APIs that I can use to query this object. I have very little experience in RIA/Silverlight/Entity Models and I am wondering what the best way (or usual way) to go about "wrapping" this object, making it queryable, and putting it into a domain service would be!

I would love any tips! Any direction would be better than what I have now!

Thanks!

Edit: I guess it will be:

Activator.CreateInstance(...);
//I will have to figure out how to get the remote server part to work...

Edit 2: Some more details: I am pulling back documents that look essentially like so:

InvoiceNo              | string
CompanyNumber          | string
CompanyName            | string
Date                   | datetime
DocumentDescription    | string
UserID                 | string

I am pulling them back from MyObject.Application so that I can compare them, for each date, to documents from our SQL Server database (which is simple to set up RIA for).

I have the methods to login/find/modify/delete (which should never happen) documents from MyObject.Application and am able to execute them... So it's just how to set up the wrapper class/DomainService/etc.... Thanks!


Solution

  • Presumably your data services work with particular types of object. You will need data objects to hold that "shape" of data and add various attributes. The only required requirement is a property with a [key] attribute so that instances of your objects can be uniquely identified.

    To make it work with RIA Services you need to create CRUD methods for each object type. There are a few common variant possible on the methods names (change vs update etc), and you have [Create], [Read], [Update] & [Delete] attributes if you want to break the standard altogether.

    The various methods are called automatically by RIA Services, so all you have to do is worry about the add of 1 object, the delete of 1 object, the update of 1 object, or returning an IQuerable (or at least an IEnumerable) of your object in the read method. You implement the actual storage any way you like.

    If you post more detail about you objects I can post a specific example.