コード例 #1
0
        public string Delete(string dataobject, bool autoCommit, string filter, params object[] keyValue)
        {
            var dataStore = new DataStore(dataobject, _context);

            var count = dataStore.Retrieve(keyValue);

            if (count > 0)
            {
                if (autoCommit)
                {
                    _context.BeginTransaction();
                }
                if (filter.Length > 0)
                {
                    dataStore.SetFilter(filter);
                    dataStore.Filter();
                }

                for (var i = dataStore.RowCount - 1; i >= 0; i--)
                {
                    dataStore.DeleteRow(i);
                }

                dataStore.Update();

                if (autoCommit)
                {
                    _context.Commit();
                }
            }

            return("Success");
        }
コード例 #2
0
        public string Delete <TModel>(bool autoCommit,
                                      Predicate <TModel> predicate, params object[] parameters)
            where TModel : class, new()
        {
            var modelList = Retrieve <TModel>(parameters)
                            .TrackChanges(ChangeTrackingStrategy.PropertyState);

            modelList.RemoveAll(predicate);

            if (autoCommit)
            {
                _context.BeginTransaction();
                modelList.SaveChanges(_context);
                _context.Commit();
            }
            else
            {
                modelList.SaveChanges(_context);
            }

            return("Success");
        }