示例#1
0
 private void DeleteXrefItem(L item, Database db)
 {
     if (XrefsByListId.ContainsKey(item.IdValue.Value))
     {
         XrefsByListId[item.IdValue.Value].Delete(db);
     }
 }
示例#2
0
        /// <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();
            }
        }
示例#3
0
        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);
            }
        }