The DomainDataSource.Data collection only contains entities of a single type. If you want to add or remove from that collection of entities, you should use DomainDataSource.DataView.Add or Remove. In the example you mention, Event is the primary type and
it contains EventTracks which contain Talks. For adding a new Event you can use the DataView, but for adding the other types you need to use the Add method on the generated EntityCollections (EventTracks, Talks).
aadiver
Member
6 Points
7 Posts
Re: Re: July CTP DomainDataSource.DomainContext.Entity.Add no longer updates DomainDataSource.Data
Sep 23, 2010 08:21 AM | LINK
On the example of the Silverlight site :
http://channel9.msdn.com/Learn/Courses/Silverlight4/SL4BusinessModule2/SL4LOB_02_Event_Manager/Exercise-4-Track-and-Session-Hierarchy
DataView is not used for adding tracks and talks.
So would it be possible to explain in more detail when to use dataview or the DomainContext?
http://channel9.msdn.com/Learn/Courses/Silverlight4/SL4BusinessModule2/SL4LOB_02_Event_Manager/Exercise-4-Track-and-Session-Hierarchy
private void newTrackButton_Click(object sender, RoutedEventArgs e)
{
Event currentEvent =
eventDomainDataSource.Data.Cast<Event>().Single();
currentEvent.EventTracks.Add(new EventTrack
{ EventTrackTitle = "New Track" });
}
private void newTalkButton_Click(object sender, RoutedEventArgs e)
{
EventTrack track =
eventTracksDataGrid.SelectedItem as EventTrack;
if (track != null)
{
track.Talks.Add(new Talk { TalkTitle = "New Talk" });
}
}
kylemc
Contributor
7243 Points
1147 Posts
Microsoft
Re: Re: July CTP DomainDataSource.DomainContext.Entity.Add no longer updates DomainDataSource.Data
Sep 23, 2010 02:43 PM | LINK
The DomainDataSource.Data collection only contains entities of a single type. If you want to add or remove from that collection of entities, you should use DomainDataSource.DataView.Add or Remove. In the example you mention, Event is the primary type and it contains EventTracks which contain Talks. For adding a new Event you can use the DataView, but for adding the other types you need to use the Add method on the generated EntityCollections (EventTracks, Talks).
aadiver
Member
6 Points
7 Posts
Re: Re: July CTP DomainDataSource.DomainContext.Entity.Add no longer updates DomainDataSource.Data
Sep 28, 2010 07:23 AM | LINK
Thanks for this clarification.
aadiver
Member
6 Points
7 Posts
Re: Re: July CTP DomainDataSource.DomainContext.Entity.Add no longer updates DomainDataSource.Data
Oct 20, 2010 02:04 PM | LINK
When using the MVVM pattern how can I access the DataView?
Can you give a small code example?
But normally a viewmodel should not be dependent on the view, but with the change implemented we need to use the dataview.