private LetterRelationshipTailDTO ToLetterRelationshipTailDTO(EntityLetterRelationshipTails item, bool withDetails)
        {
            LetterRelationshipTailDTO result = new LetterRelationshipTailDTO();

            result.EntityID           = item.TableDrivedEntityID;
            result.ID                 = item.TableDrivedEntityID;
            result.RelationshipTailID = item.EntityRelationshipTailID;
            if (withDetails)
            {
                BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();
                result.RelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
            }
            return(result);
        }
 public bool UpdateLetterRelationshipTails(int entityID, List <LetterRelationshipTailDTO> list)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var entity = projectContext.TableDrivedEntity.First(x => x.ID == entityID);
         while (entity.EntityLetterRelationshipTails.Any(x => x.TableDrivedEntityID == entityID))
         {
             projectContext.EntityLetterRelationshipTails.Remove(entity.EntityLetterRelationshipTails.First(x => x.TableDrivedEntityID == entityID));
         }
         foreach (var item in list)
         {
             EntityLetterRelationshipTails dbItem = new EntityLetterRelationshipTails();
             dbItem.TableDrivedEntityID      = entityID;
             dbItem.EntityRelationshipTailID = item.RelationshipTailID;
             projectContext.EntityLetterRelationshipTails.Add(dbItem);
         }
         projectContext.SaveChanges();
     }
     return(true);
 }