locked
Insert record - EDMX/DomainService RRS feed

  • Question

  • Hello,

    Thanks to a couple EDMX / Domain service, I can access the drawings and records in the given base.

    But I can not do is to add elements to a table.

    Ex: I have a table: myTable => So a class MyTable is created, and records of this table are accessible through the service area: myDomainService.MaTables is a list of MyTable

    So to add an item:

    MyTable aRecord= new MyTable ();
    / / Information collumns
    . . .
    / / Add the line:
    myDomaineContext.MaTables.Add (aRecord);
    / / Save.
    myDomaineContext.SaveChanges ();


    My code is executed without error, but I cant  find my line in the database.

    Any idea of a way to fix that?

    Monday, October 10, 2011 5:43 AM

Answers

  • You have to add the Webapplication reference in silverlight project, then you can get the domainservice class.

    Monday, October 10, 2011 9:39 AM

All replies

  •   void btnInsert_Click (object sender, RoutedEventArgs e)
            {
                datacontext = new DomainService1();
                Employee emp = new Employee();
                emp.Name = txtname.Text;
                emp.State = txtstate.Text;
                emp.DoorNo = txtdoorno.Text;
                emp.Country = txtcountry.Text;
                emp.City = txtcity.Text;
    
                datacontext.Employees.Add(emp);
                datacontext.SubmitChanges();
                
            }
    Monday, October 10, 2011 6:26 AM
  • Hi

    I did exactly the same thing, but dataContext is not a DomainService instance, it's a DomainContext :

    private MyDomainContext dataContext = new MyDomainContext(new Uri(rootPath + Resource.param_pathDomainService));

    I can't call MyDomainService in this part of my program ( i dont event know why).

    Monday, October 10, 2011 7:58 AM
  • You have to add the Webapplication reference in silverlight project, then you can get the domainservice class.

    Monday, October 10, 2011 9:39 AM