This is a migrated thread and some comments may be shown as answers.

DomainDataSource MVVM and editing

5 Answers 112 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 16 Jun 2011, 12:53 PM
I have used your sample code to see if i can get the DomainDataSource to work with MVVM.
It works like a dream very little code.
However i would like to allow the user to edit the entities.
How can i change the code from yoru sample (bellow) to allow for that?

RabbitDomainContext _context = new RabbitDomainContext();
          
public ClientsViewModel()
{
    if (!DesignerProperties.IsInDesignTool)
    {
        EntityQuery<Organisation> getOrganisationQuery = _context.GetOrganisationsQuery();
        _organisations = new QueryableDomainServiceCollectionView<Organisation>(_context, getOrganisationQuery);
        _organisations.PageSize = 25;
        _organisations.AutoLoad = true;
    }
             
}
  
private readonly QueryableDomainServiceCollectionView<Organisation> _organisations;
          
public IEnumerable Organisations
{
    get { return _organisations; }
}

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 16 Jun 2011, 12:58 PM
Hello Andrew,

So what is the exact problem? Why can't you edit? Could you be a little bit more specific? 

Greetings,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 16 Jun 2011, 01:20 PM
i am a little bit confused at your question. Perhaps i do not understand how RadDomainDataSource works.
I asume that i would require a to change my code to something like this to allow for editing:

private QueryableDomainServiceCollectionView<Organisation> _organisations;
          
        public IEnumerable Organisations
        {
            get { return _organisations; }
            set
            {
                if (value != _organisations)
                {
                    _organisations = value;
                    OnPropertyChanged("Organisations");
                }
            }
        }


However that gives me an error when i try to assign "_organisations = value"
Error message is:
Cannot implicitly convert type 'System.Collections.IEnumerable' to 'Telerik.Windows.Data.QueryableDomainServiceCollectionView<cint.Rabbit.Shell.Web.Models.Organisation>'.
0
Accepted
Rossen Hristov
Telerik team
answered on 16 Jun 2011, 01:40 PM
Hi Andrew,

I am really not sure why you are doing all of this. A collection property that has a setter and raises PropertyChanged is against all design principles of .NET. Also, how is this connected with editing anyway? I am not sure why you are doing this, but take my word and don't do it.

Please read all of these blog posts before trying to go on. Don't just read them, but download the sample project in each one and examine it carefully in order to understand how the control works:

The blog post with the CRUD in the title demonstrates how you can edit data.

After you have covered the blog posts, please read the documentation.

After reading all of these resources, let us know if you have any specific questions. We will be glad to answer any question as long as it is specific and well informed.  Regards,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 16 Jun 2011, 03:58 PM

I see, yes that does explain it very well.
I have not added a dataform and am able to edit the object and submit with very little additional code.
Thanks

By the way the CRUD example, there is a problem with the project files. I had to edit the solution file to get it to work. Also files appear to be duplicated; you might want to fix that,

0
Jerry T.
Top achievements
Rank 1
answered on 19 Jul 2011, 04:41 PM
The link to the blog entry on CRUD operations is a dead link.

Is this supposed to be it?
http://blogs.telerik.com/silverlightteam/posts/10-12-28/creating-crud-application-with-raddomaindatasource-for-silverlight.aspx


Nope...that ain't it.    
Tags
DomainDataSource
Asked by
Andrew
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Andrew
Top achievements
Rank 1
Jerry T.
Top achievements
Rank 1
Share this question
or