views:

107

answers:

1

I have two tables in my database: Books and Categories. In my EDMX I have generated classes Book and Category, and correspondingly BookSet and CategorySet. I created BookService and can access it in my SilverLight code via BookContext.

Through BookContext I am able to load a list of all books. My problem right now is I am trying to add a Book to my database via this context. However, when I try to add the category information to suffice the foreign key constraint, I am not able to do so.

I have searched Google far and wide but I am not able to see code for how to do this with a POCO. Can anyone assist?

Thanks in advance

A: 

I'm pretty sure that it would be something like this.

Book book = new Book();
Category category = new Category();
book.Title = title;

BookContext.Books.Add(book);
book.Category = category;

SubmitChanges(null);
thepaulpage
On the server yes, but that wont work from the client I wager
xximjasonxx
I would tell you that it would work every time because this is what we do on the client, but you mentioned something about POCOs and we just use the generated entityClasses so, while I assume it will work the same way, I am not sure.
thepaulpage