Shilpa Katre

Shilpa Katre

  • NA
  • 54
  • 28.8k

Insert Data Using RIA Service

Jul 22 2011 1:11 AM
 I am enable to insert the data using RIA service,Please tell..How to use RIA service for insert the data in table from client side using silverlight 4?


/*This is my Domain Service code*/
 public void insertData(CarBind data)
        {      
            if (data.EntityState != EntityState.Added)
            {
              
                if ((data.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(data, EntityState.Added);
                }
                else
                {
                    this.ObjectContext.AddToCarBinds(data);
                }
            }
        }

/*This is my client side code */

 private void Add_Click(object sender, RoutedEventArgs e)
        { 
            var context = new DomainService1();
            CarBind car = new CarBind();
            car.Car_No =Convert.ToInt32(textbxCarNo.Text);
            car.Car_Name = textbxCarName.Text;
            car.Car_Price = Convert.ToInt32(textbxCarPrice.Text);
         
            context.CarBinds.Add(car);
         
                     
        }



Answers (2)