Question

I am working on a N-tier Silverlight 4.0 solution using WCV RIA services, Domain Services and Entity Framework.

  1. I have created the Entity Framework model and Domain Services in my DAL project.
  2. Having clicked the 'Enable Client Code Generation' whilst creating the Domain Service everything works fine. The generated code is created in the client application as I can see the .g.cs file.
  3. I decided to add a stored procedure to the EF model by adding a function and creating a complex type.
  4. Then I proceeded to add this code to my Domain Service (MyDomainService.cs) class as shown below:

    public IQueryable GetJournalItemList() { return this.ObjectContext.ExecuteFunction("GetJournalList", null).AsQueryable(); }

The problem I'm facing now is that when I build my solution I cannot see the new code in the client generated code class (.g.cs) in Silverlight client application. The proxy has no reference to the new GetJournalItemList which references the newly added stored procedure.

So here's my question: how to force a refresh of the client generated code so changes to the Domain Service class can be shown?

Thank You

Was it helpful?

Solution

You must return a strongly typed result. i.e.

public IQueryable<JournalItemList> GetJournalItemList() 
{ 
     return this.ObjectContext
       .ExecuteFunction("GetJournalList", null).AsQueryable(); 
}

In addition, if this has not already been done, JournalItemList must have a key defined. You can do this using a Metadatatype attribute through a custom partial class. When you generate the Domain Service, a .metadata.cs file would have been created. There should be examples you can use.

[MetadataType(JournalItemList.Metadata)]
public partial class JournalItemList
{
    public class Metadata
    {
        // Assuming that JournalItemList.JournalItemId exists
        [Key]
        public int JournalItemId { get; set; }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top