views:

1843

answers:

2

Hello everbody!

Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created an EF Model (no POCOs), generic repository on top of it and a RIA Service(hosted in an ASP.NET MVC application) and tried to get data from within the ASP.NET MVC application: worked well. Next step: Silverlight client. Got a reference to the RIAService (through its context), queried for all the records of the repository and got them into the SL application as well (using this code sample):

private ObservableCollection<Culture> _cultures = new ObservableCollection<Culture>();
public ObservableCollection<Culture> cultures
{
  get { return _cultures; }
  set
  {
    _cultures = value;
    RaisePropertyChanged("cultures");
  }
}

....

//Get cultures            
EntityQuery<Culture> queryCultures = from cu in dsCtxt.GetAllCulturesQuery()
                                             select cu;
loCultures = dsCtxt.Load(queryCultures);
loCultures.Completed += new EventHandler(lo_Completed);

....

void loAnyCulture_Completed(object sender, EventArgs e)
{
  ObservableCollection<Culture> temp= 
  new ObservableCollection<Culture>loAnyCulture.Entities);
                AnyCulture = temp[0];
}

The problem is this: whenever i try to edit some data of a record (in this example the first record) i get this error: This EntitySet of type 'Culture' does not support the 'Edit' operation.

I thought that i did something weird and tried to create an object of type Culture and assign a value to it: it worked well!

What am i missing? Do i have to declare an EntitySet? Do i have to mark it? Do i have to...what?

Thanks in advance

+6  A: 

It turns out that in the DomainService class one has to implement (or at least to mark "placeholder methods") as "Edit", "Delete",... eg

[Delete]
public void DeleteCulture(Culture currentCulture)
{
   throw new NotImplementedException("UpdateCulture not Implemented yet");
}
[Insert]
public void InsertCulture(Culture newCulture)
{
   throw new NotImplementedException("InsertCulture not Implemented yet");
}

This way the OrganizationDomainContextEntityContainer class creates an EntitySet with parameter EntitySetOperations.All (meaning that all the CUD operations are available).

Hope it's useful for someone in the future!

Savvas Sopiadis
A: 

Thanks Sawas, It was really useful for me

Afsal

Sayyed Afsal