Click to See Complete Forum and Search --> : LINQ. Insert. How can I do this?


Shapper
June 27th, 2008, 07:23 AM
Hello,

I have 3 tables:

Files > FileID, Url, ...
Tags > TagID, Name, ...
FilesTags > FileID, TagID, ...

FilesTags is used to associate tags to each file.

Before I update a file I have the following data:
1. File Data
2. List of File Tags (TagsList)

I need to:
1. Update File Data (This is done)
2. Update File Tags ...

I am having problems updating the file tags using LINQ.

The sequence I am trying to create is:

FOR each Tag in TagsList {

Exists = Find Tag in Tags table given its name

IF Not Exists > Create Tag in Tags table using the Name

Use found or created Tag ID and add record to FilesTags with FileID and TagID
END

How can I translate this to LINQ?

Thanks,
Miguel