Advertisement

12.29.2007 at 02:29PM PST, ID: 23049249
[x]
Attachment Details

Linq Relationships

Asked by shanewho in Language Integrated Query - LINQ, Microsoft Visual C#.Net, .NET Framework 3.x versions

Tags:

(a link to an image of the class designer and app is below)

I have 2 linq to sql classes, Place and PlaceType.  A place is a restaurant and PlaceType is the type of food.  To add a new place, you give it a name and select the PlaceType from the combobox (which is bound to a query's results).  This works fine when I change an existing PlaceType, but when I try to add a new one with the code below, I get a sql error because it is trying to insert a new PlaceType.  Why is it trying to insert a new PlaceType when I only want to insert a new Place and use the existing PlaceType?

See the Image here: http://allyoucanupload.webshots.com/v/2006023520909293090Start Free Trial
1:
2:
3:
//BusinessLayer.Database.DataContext.Places.InsertOnSubmit(this);  
BusinessLayer.Database.DataContext.Places.Attach(this); 
BusinessLayer.Database.DataContext.SubmitChanges();  //Exception is thrown here
[+][-]01.01.2008 at 05:11AM PST, ID: 20559521

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.01.2008 at 05:41AM PST, ID: 20559594

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.01.2008 at 02:10PM PST, ID: 20561574

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.03.2008 at 03:30AM PST, ID: 20571981

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.04.2008 at 04:10PM PST, ID: 20587169

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.09.2008 at 10:01AM PST, ID: 20620505

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.21.2008 at 09:36AM PST, ID: 20707839

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Language Integrated Query - LINQ, Microsoft Visual C#.Net, .NET Framework 3.x versions
Tags: .net 3.x
Sign Up Now!
Solution Provided By: Praesidium
Participating Experts: 3
Solution Grade: A
 
 
[+][-]03.19.2008 at 05:22PM PDT, ID: 21167185

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628