4

Framework: Silverlight 4 + Entity Framework 4 (SL business application: SL project and .WEB project in a solution)

I have two classes in my Data Layer (not mapped to DB, created manually - I need them for specific view)

[EnableClientAccess]
public class CityInfoFull
{
    [Key]
    public int Id { get; set; }

    public String Country{ get; set; }
    public String Region { get; set; }
    public String City { get; set; }
    public int Population { get; set; }
    public DateTime Founded { get; set; }
}

The RIA generates the appropriate proxy class in the Geography.Web.g.cs

In the same namespace, I have another class:

[EnableClientAccess]
public class Person
{
    [Key]
    public int Id { get; set; }

    public String FullName { get; set; }
    public DateTime DateOfBirth { get; set; }
}

However, RIA does not want to generate the proxy for this class. I need the proxy in Silverlight application and it is not generated.

What could be the reason for that? I don't know where to look anymore.

I've tried:

  • Checked that the file is set to Compile
  • Checked that the file is in the appropriate namespace
  • Rebuilt the web project that contains the file
  • Rebuilt the SL project
  • Deleted the .g.cs file and rebuilt the projects.
  • Checked if any other proxy classes are generated. (I have found out that any new class I create won't have the proxy, but if I change already existing classes, their proxies will be updated. But no new proxies are created. It seems that only the classes created before some point are generated and everything created since then does not get its proxy, not even if I delete the .g.cs and let RIA regenerate the .g.cs).

None of this worked. What else can I do?

Jehof
  • 34,674
  • 10
  • 123
  • 155
Kornelije Petak
  • 9,412
  • 15
  • 68
  • 96
  • Do you defined a query operation for CityInfoFull and Person? – Jehof Oct 05 '11 at 13:30
  • 1
    I have defined one for CityInfoFull but I haven't for Person. Please don't tell me the RIA framework generates the entities only if they are used in some Query/Invoke operation... there goes my morning... ;) If that's true, could you please form this as an answer so we can conclude this question. – Kornelije Petak Oct 05 '11 at 14:07

1 Answers1

5

You need to define a query method in your domain service for each entity you want to use in the silverlight project. In your case you must define a query operation for CityInfoFull and Person.

public class MyDomainSerivce : DomainService {

   public IQueryable<CityInfoFull> GetCities() {
     // your logic
   }

   public IQueryable<Person> GetPersons() {
     // your logic
   }
}

If you want to allow that entites of the specified types can be inserted, updated and removed in the silverlight application you need to define corresponding Insert-, Update- and Remove-Operations in your DomainService for the entities.

Take a look at the WCF RIA Services documentation to get more details.

Jehof
  • 34,674
  • 10
  • 123
  • 155