locked
domainContext.submitChanges doesnt insert in database RRS feed

  • Question

  •     
    
    Hi. I'm adding object to a list of objects as composition or master- detail
    
    it list the object in the datagrid details of the selected item in the master, but the submitchanges dont's insert data in database.
    
     
    
     
    
     private void button4_Click(object sender, RoutedEventArgs e)
        {
          ChildWindowHorizonte cw = new ChildWindowHorizonte(new Horizonte());
          cw.Closed += new EventHandler(cw_ClosedNuevoHorizonte);
          cw.Show();
        }
    
        void cw_ClosedNuevoHorizonte(object sender, EventArgs e)
        {
            ChildWindowHorizonte cw = ((ChildWindowHorizonte)sender);
            Horizonte _horizonte = (Horizonte)(cw.DataFormHorizonte.CurrentItem);
            if (cw.DialogResult==true)
            {
              cw.DataFormHorizonte.CommitEdit();
              ((Observacion)observacionDataGrid.SelectedItem).Horizonte.Add(_horizonte);
              observacionesDomainDataSource.SubmitChanges();
            }
          }
        
    

     

    In the xaml i use a global context:

    <Grid x:Name="LayoutRoot">
        <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Observacion, CreateList=true}" 
                       Height="0" 
                       LoadedData="observacionesDomainDataSource_LoadedData" 
                       SubmittedChanges="observacionesDomainDataSource_SubmittedChanges" 
                       x:Name="observacionesDomainDataSource" 
                       QueryName="GetObservacionQuery" Width="0"
                       DomainContext="{StaticResource DomainContext}">
        </riaControls:DomainDataSource>
       
    

    in the domainServiceClass

     public IQueryable<Observacion> GetObservacion()
        {
          return this.ObjectContext.Observacion.Include("Horizonte").Include("Pendiente");
        }
    

    In the  domainServiceClass.metadata for observacion Class

     [Include]
          public EntityCollection<Horizonte> Horizonte { get; set; }

    What's wrong?

     

    Thanks in advance

    Monday, September 27, 2010 3:30 AM

All replies