If Not Exists
Is there a better way?
internal
staticvoid CreateTag(String tag){
// instance the data contextusing (DiamondDataContext dc =newDiamondDataContext())
{
// construct queryvar resultQuery =from tin dc.Tagswhere t.Name.Equals(tag)select t;
// if this tag exists already, move on.
if (resultQuery.Count<Tag>() == 0){
// create the new tagTag newTag =newTag();// assign the value
newTag.Name = tag;
// add it to the collectiondc.Tags.Add(newTag);
// save itdc.SubmitChanges();
}
}
}

