private void DeleteXrefItem(L item, Database db) { if (XrefsByListId.ContainsKey(item.IdValue.Value)) { XrefsByListId[item.IdValue.Value].Delete(db); } }
/// <summary> /// Removes the specified item from this collection, deletes the xref entry but /// does not delete the item from the database /// </summary> /// <param name="item"></param> public void Remove(L item) { if (_values.Contains(item)) { _values.Remove(item); _book = new Book <L>(_values); } if (XrefsByListId.ContainsKey(item.IdValue.Value)) { XrefsByListId[item.IdValue.Value].Delete(); } }
private X EnsureXref(L item, Database db = null) { db = db ?? Database; if (item.IdValue != null && XrefsByListId.ContainsKey(item.IdValue.Value)) { return(XrefsByListId[item.IdValue.Value]); } else { if (item.IsNew) { item.Save(db); } X result = null; QuerySet q = Dao.GetQuerySet(db); q.Select <X>().Where(new QueryFilter(ListColumnName) == item.IdValue.Value && new QueryFilter(ParentColumnName) == Parent.IdValue); q.Execute(db); if (q.Results[0].DataTable.Rows.Count > 0) { result = new X(); result.DataRow = q.Results[0].DataTable.Rows[0]; } else { result = new X(); result.SetValue(string.Format("{0}Id", Parent.GetType().Name), Parent.IdValue); result.SetValue(string.Format("{0}Id", typeof(L).Name), item.IdValue); result.Save(db); XrefsByListId.Add(item.IdValue.Value, result); } return(result); } }