Exemplo n.º 1
0
        public void SubmitChanges()
        {
            _context.CheckThrow();
            var ids     = _metaTable.RowType.IdentityMembers;
            var autoIds = ids.Where(id => id.IsDbGenerated);

            if (autoIds.Count() > 1)
            {
                throw new NotImplementedException("Can't handle more than one auto-generated identity column!");
            }

            lock (lockObj) {
                foreach (var insert in _insert)
                {
                    if (autoIds.Count() > 0)
                    {
                        ((PropertyInfo)autoIds.First().Member).SetValue(insert, _nextId++, null);
                    }

                    _stored.Add(insert);
                }

                foreach (var entity in _delete)
                {
                    _stored.Remove(entity);
                }

                _insert.Clear();
            }
        }
Exemplo n.º 2
0
 public TResult Execute <TResult>(Expression expression)
 {
     _context.CheckThrow();
     return(_provider.Execute <TResult>(Visit(expression)));
 }