public static void DeleteDataTag(long dataTagId) { DataTagShip dt = DataTagShip.findById(dataTagId); if (dt == null) { return; } long tagId = dt.Tag == null ? 0 : dt.Tag.Id; dt.delete(); if (tagId == 0) { return; } int count = DataTagShip.count("TagId=" + tagId); Tag tag = Tag.findById(tagId); if (tag == null) { return; } tag.DataCount = count; tag.update(); }
private static void recountTagDatas(List <Tag> tags) { foreach (Tag tag in tags) { int count = DataTagShip.find("Tag.Id=" + tag.Id).count(); tag.DataCount = count; tag.update("DataCount"); } }
public static void DeleteTag(long tagId) { Tag tag = Tag.findById(tagId); if (tag == null) { return; } DataTagShip.deleteBatch("TagId=" + tagId); tag.delete(); }
private static void clearDataTags(IAppData data) { List <DataTagShip> list = DataTagShip.find("DataId=:dataId and TypeFullName=:dataType") .set("dataId", data.Id) .set("dataType", data.GetType().FullName) .list(); foreach (DataTagShip ship in list) { db.delete(ship); } }
private void initDataTagList() { List <DataTagShip> list = DataTagShip.find("DataId=" + _data.Id + " and TypeFullName=:tname order by Id").set("tname", _data.GetType().FullName).list(); _dataTags = list; _tags = new List <Tag>(); foreach (DataTagShip dt in list) { _tags.Add(dt.Tag); } }
private static void joinTag_Data(Tag tag, IAppData data) { if (DataTagShip.find("DataId=:dataId and Tag.Id=:tagId and TypeFullName=:dataType") .set("dataId", data.Id) .set("tagId", tag.Id) .set("dataType", data.GetType().FullName) .count() == 0) { DataTagShip ship = new DataTagShip(); ship.DataId = data.Id; ship.TypeFullName = data.GetType().FullName; ship.Tag = tag; db.insert(ship); } }