/// <summary> /// 将指定的标签项贴入实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="tagInfo">标签,需要指定ID属性</param> /// <param name="entity">要贴入标签的实体,需要指定ID属性</param> /// <returns></returns> public ITag Apply <T>(SYSTag tagInfo, T entity) where T : Entity, new() { tagApplyBO.Save(new SYSTagApply { TagID = tagInfo.ID, TargetID = tagTargetBO[entity.Property.TableAttribute.TableName].ID, TargetObjectID = ALConvert.ToLong(entity.Property.GetValue(entity.Property.TableAttribute.PrimaryKey)) }); return(this); }
/// <summary> /// 将指定的标签项贴入多个实体 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="tagInfo">标签,需要指定ID属性</param> /// <param name="entity">要贴入标签的实体,需要指定ID属性</param> public ITag Apply <T>(SYSTag tagInfo, List <T> entity) where T : Entity, new() { List <SYSTagApply> tagApplyInfo = new List <SYSTagApply>(); entity.ForEach(d => { tagApplyInfo.Add(new SYSTagApply { TagID = tagInfo.ID, TargetID = tagTargetBO[d.Property.TableAttribute.TableName].ID, TargetObjectID = ALConvert.ToLong(d.Property.GetValue(d.Property.TableAttribute.PrimaryKey)) }); }); tagApplyBO.Save(tagApplyInfo); return(this); }