Click here to Skip to main content
13,189,324 members (65,307 online)
Rate this:
Please Sign up or sign in to vote.

When creating the domain ria services, we should make one service for each table or one service for all tables??

I'm asking this cause i created one service for each table, and worked fine with simple tables. But now i'm having problems with Parent/child tables...

private ParentMetadata()
            public Child Child{ get; set; }
            public string desc { get; set; }

Service Code for Parent

public IQueryable<Parent> GetParent()
            return this.ObjectContext.Parents.Include("Child");

And in the insert method i have:

private void OKButton_Click(object sender, RoutedEventArgs e)
            Web.Services.ParentContext context;  
            context = new Web.Services.ParentContext();
            WMS.Web.Model.Parent obj = new WMS.Web.Model.Parent();
            Guid obj2 = Guid.NewGuid();
            obj.GUIDParent = obj2;
            obj.desc = descTextBox.Text;
            obj.Child.GUIDParent = obj2;
            obj.Child.desc = descTextBox.Text;
                this.DialogResult = true;
            catch (Exception ex)
                MessageBox.Show("Error: " + ex.Message);
                this.DialogResult = false;

I'm always getting an error saying that obj.Child is null
Posted 25-Jul-12 7:35am
Updated 25-Jul-12 9:48am
Karl Sanford 25-Jul-12 15:33pm
What kind of problems are you having? We can't help if we don't know what's wrong.
renabee 25-Jul-12 15:48pm
Updated the question, thx :D
Karl Sanford 25-Jul-12 16:00pm
Could you try to initialize the Child property of the parent before you use it? Some thing like: obj.Child = new WMS.Web.Model.Child();
renabee 25-Jul-12 16:21pm
Yes, it gives an error saying that obj.Child dont have an add method.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Is recomendable that you create one service for all tables. But this is not a limitation.

Have you got Navigation property on your Entity Framework Model?

Must have a relation in the model and Database of course.

Hope it helps.
renabee 25-Jul-12 20:36pm
thanks, it worked creating one service to all tables.
Christian Amado 25-Jul-12 20:45pm
Sounds very good. Enjoy it! =)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171016.2 | Last Updated 25 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100