Example #1
0
        public override void Create(IEnumerable <TModel> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }
            try
            {
                var result = xpo.Execute((db, w) =>
                {
                    foreach (var item in items)
                    {
                        bool ok = val.Inserting(item);
                        if (!ok)
                        {
                            throw new Exception(String.Format("Validator failed on Inserting on '{0}'", XpoType.Name));
                        }

                        var newItem = Assign(item, Activator.CreateInstance(typeof(TXPOClass), new object[] { w }) as TXPOClass);
                        //TODO: Move to Validator Inserted
                        //newItem.AddStampUTC = DateTime.UtcNow;
                        //newItem.ModStampUTC = DateTime.UtcNow;
                        ok = val.Inserted(item, newItem);
                        if (!ok)
                        {
                            throw new Exception(String.Format("Validator failed on Inserted on '{0}'", XpoType.Name));
                        }
                    }
                    return(0);
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
 protected virtual void XPOExecute(Action <XpoDatabase, Session> work, bool transactional = true)
 {
     _Database.Execute(work, transactional);
 }