views:

112

answers:

3

I'm trying to create a function that takes any table from my ADO.NET Data Model in Silverlight. I can't figure out what the base class is for the Entity Objects that it creates for me. Each Entity in the model is of this type:

global::System.Data.Objects.DataClasses.EntityObject

but that type wasn't working in SilverLight.

I'd like to do something like this:

   public void foo(WhatGoesHere entityObject)
    {
        //Use entityObject to manipulate the DB
    }

So: What types of Silverlight objects are they?

A: 

Just right click on one of your models and select "Go To Definition". You can see the class definition from there.

Joel Martinez
+2  A: 

Silverlight is a subset of the dotnet framework.

I am guessing that Entity Framework is one of the things that is not included in Silverlight.

You could build the system with a WCF service between silverlight and the database. Your silverlight app talks to the service using WCF, and your service gets data from the database and maps them to data transfer objects to be sent to the silverlight app.

That last point with mapping the data will not be required in the next version of Entity Framework, since it uses POCO (Plain Old CLR Objects)

Shiraz Bhaiji
POCOs are a non-issue if you use the correct solution to the problem (RIA Services). Actually so-called POCOs (which are actually proxies in an ORM context) are *broken* when they cross tiers, as the change tracking you expect will cease to function, at least, unless you do a lot of work.
Craig Stuntz
This solution will require a lot more work than either RIA Services or ADO.NET Data Services. There's no need to use POCOs and build the plumbing yourself with WCF.
James Cadd
+1  A: 

You could worry about base classes and POCOs and how you're going to manually map object changes and queries into WCF calls, or you could use RIA Services, which are designed to map EF models to Silverlight without fuss and worry. It's still in preview, but the go-live restriction has been removed and this will be by far the easiest solution, even with possible preview bugs.

RIA Services are explicitly designed for the problem you're presently trying to solve. Don't reinvent the wheel!

Craig Stuntz
RIA Services is definitely the best way to go if you're already using EF. ADO.NET Data Services is the other option. +1
James Cadd
After looking into RIA Services, I think you might be correct
thepaulpage