public void AddTagOfDoc(int tagId, int documentId) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { DocumentTag dbTagDoc = new DocumentTag { TagId = tagId, DocumentId = documentId }; try { context.AddToDocumentTags(dbTagDoc); context.SaveChanges(false); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.InnerException.Message); } } }
/// <summary> /// 用于向 DocumentTags EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToDocumentTags(DocumentTag documentTag) { base.AddObject("DocumentTags", documentTag); }
/// <summary> /// 创建新的 DocumentTag 对象。 /// </summary> /// <param name="id">Id 属性的初始值。</param> /// <param name="documentId">DocumentId 属性的初始值。</param> /// <param name="tagId">TagId 属性的初始值。</param> public static DocumentTag CreateDocumentTag(global::System.Int32 id, global::System.Int32 documentId, global::System.Int32 tagId) { DocumentTag documentTag = new DocumentTag(); documentTag.Id = id; documentTag.DocumentId = documentId; documentTag.TagId = tagId; return documentTag; }