Thread: Linq Problem
View Single Post
  #5 (permalink)  
Old June 9th, 2010, 09:10 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I was just going to suggest that after I tried your SQL script ;-)

LINQ to SQL needs some way to uniquely identify an object. It uses the primary key for that. Otherwise, it cannot track objects.

You don't *have* to add a surrogate primary key (e.g. one that's there purely to make records unique). If you can create one from the columns in the Track table, that's OK too. For example, if sono and track together are unique (e.g. sono can occur multiple times, with unique values for track), then you can create a composite key. To do this, open the database diagram, select both the sono and track columns and click the key icon. Then recreate the LINQ to SQL diagram and your Tracks collection appears for the Order object. You may want to / have to rename the track column as having a class name that is also a property name will get you into troubles.

FYI:
Quote:
don't know waht more to add here
Nothing, This is exactly the type of information needed for a good post and a quick answer.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote