Click here to Skip to main content
11,709,529 members (50,090 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# entity RIA Silverlight5 , +

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
Edited 25-Jul-12 9:48am
Karl Sanford at 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 at 25-Jul-12 15:48pm
Updated the question, thx :D
Karl Sanford at 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 at 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 at 25-Jul-12 20:36pm
thanks, it worked creating one service to all tables.
Christian Amado at 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
0 Sergey Alexandrovich Kryukov 590
1 OriginalGriff 250
2 Maciej Los 225
3 Peter Leow 219
4 Mika Wendelius 160
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,027
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 25 Jul 2012
Copyright © CodeProject, 1999-2015
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