TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Amit Shah
NA
5
3.2k
Adding row to relational table - linq to sql
Jun 15 2011 12:50 AM
Hello,
I have issue that when I try to add any data in relational table it tries to add that in Primary table to. But Since I already have that record in Primary I get an exception
Here's the scenario.
I have 3 primary Tables - Picture, Album and Collage and two relational table AlbumPicture and CollagePicture.
AlbumPicture and CollagePicture can have same picture but it is not mandatory. Picture in both table can exist independently.
My problem is I have a picture already added in the Picture table and AlbumPicture table. When I try to add this existing picture and new Collage to the CollagePicture table, It throws primry key violation error on PK_Picture. It tries to add picture to picture table and hence the error.
This is what I do
CollagePictures.InsertOnSubmit(new CollagePicture {Collage = CollagePicture = existingPic});
I assign GUID as PK to Picture when Pictures are uploaded. In AlbumPicture I have this pictureId with Album
e.g.
AlbumPictureId [PK] = 1
AlbumId=1
PictureId = 1234567890123456
Now I want to add same Picture (1234567890123456) with Collage. I add this to CollagePicture and it tries to add to the Picture table as well. and that is when I get an exception.
Hope I was clear.
Thanks in advance
Reply
Answers (
4
)
What is the use of IQueryable in the context of Linq.
LINQ in HTML 5