//public bool Delete(GenericEntityType entity, bool isInContext)
        //{

        //    try
        //    {
        //        //_DataContext.GetTable<GenericEntityType>().Attach(entity);
        //        GetTable.DeleteOnSubmit(entity);
        //        if (_Flag)
        //        {
        //            _DataContext.SubmitChanges();
        //        }
        //        return true;
        //    }
        //    catch (Exception e)
        //    {
        //        _Logger.Error(typeof(GenericEntityType).Name + " could not be DELETED -- " + e);
        //        return false;
        //    }
        //}


        public bool Delete(IList <GenericEntityType> entityList, bool isInContext)
        {
            if (entityList == null)
            {
                _Logger.Error(typeof(GenericEntityType).Name + " list is null to DELETE!");
                return(false);
            }
            try
            {
                if (!isInContext)
                {
                    _DataContext.GetTable <GenericEntityType>().AttachAll(entityList);
                }
                GetTable.DeleteAllOnSubmit(entityList);
                if (_Flag)
                {
                    _DataContext.SubmitChanges();
                }
                return(true);
            }
            catch (Exception e)
            {
                _Logger.Error(typeof(GenericEntityType).Name + " list could not be DELETED -- " + e);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public void GetTableTest(string schema, string name, string expected)
        {
            GetTable getTable = new GetTable(GetDbConnection, new ListTableColumn(GetDbConnection, new GetTableColumnType(GetDbConnection)), new ListTableIndex(GetDbConnection, new ListTableIndexColumn(GetDbConnection)));
            var      type     = getTable.Get(AlbatrossDb, schema, name);

            Assert.Equal(expected, type.Name);
        }
        /// <summary>
        /// Create a new instance of type T.
        /// </summary>
        /// <returns></returns>
        public virtual T CreateInstance()
        {
            T entity = Activator.CreateInstance <T> ();

            GetTable.InsertOnSubmit(entity);
            return(entity);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Saves this instance.
 /// </summary>
 public void Save(bool mergeChanges = false)
 {
     if (mergeChanges)
     {
         _dataContext.Refresh(RefreshMode.KeepChanges, GetTable.ToArray());
     }
     _dataContext.SubmitChanges();
 }
Ejemplo n.º 5
0
 public int Count(IQueryFilter filter)
 {
     try
     {
         return(GetTable.RowCount(filter));
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
Ejemplo n.º 6
0
 private void ImportDataTableInDb(ref DataTable dataTableImportable, GetTable callGetTableImportableTemplate)
 {
     if (_importer == null)
     {
         this.InitializeImporter();
     }
     _importer.UploadTableInSqlServer(dataTableImportable, _connectionString);
     dataTableImportable.Dispose();
     dataTableImportable = callGetTableImportableTemplate();
     GC.Collect();
 }
 public void Add(T entity)
 {
     if (!Exists(entity))
     {
         GetTable.InsertOnSubmit(entity);
     }
     else
     {
         Update(entity);
     }
     SaveAll();
 }
 /// <summary>
 /// Return all instances of type T that match the expression exp.
 /// </summary>
 /// <param name="exp"></param>
 /// <returns></returns>
 public IList <GenericEntityType> FindAll(Func <GenericEntityType, bool> exp)
 {
     try
     {
         return(GetTable.Where <GenericEntityType>(exp).ToList());
     }
     catch (ArgumentNullException e)
     {
         _Logger.Error(typeof(GenericEntityType).Name + " object list could not be PICKED -- " + e);
         return(null);
     }
 }
 /// <summary>
 /// Return all instances of type T.
 /// </summary>
 /// <returns></returns>
 public IList <GenericEntityType> All()
 {
     try
     {
         this.DataContext.DeferredLoadingEnabled = false;
         return(GetTable.ToList());
     }
     catch (ArgumentNullException e)
     {
         _Logger.Error(typeof(GenericEntityType).Name + " object list not PICKED -- " + e);
         return(null);
     }
 }
        public void Table_GetSingle_Success()
        {
            var dict = testConfig.GetDefaultActivityArguments();

            dict["TableID"] = table1.Id;

            var act = new GetTable();

            var result = WorkflowInvoker.Invoke(act, dict);

            Assert.IsTrue((bool)result["Success"]);

            var json = result["Table"] as JObject;

            Assert.AreEqual(table1.Id, json.Value <string>("id"));
        }
        public void Table_GetSingle_NotFound()
        {
            var dict = TestConfiguration.Instance.GetDefaultActivityArguments();

            dict["TableID"] = "00000000";

            var act = new GetTable();

            var result = WorkflowInvoker.Invoke(act, dict);

            Assert.IsTrue((bool)result["Success"]);

            var json = result["Table"] as JObject;

            Assert.IsNull(json);
        }
 public bool Delete(GenericEntityType entity)
 {
     try
     {
         _DataContext.GetTable <GenericEntityType>().Attach(entity);
         GetTable.DeleteOnSubmit(entity);
         if (_Flag)
         {
             _DataContext.SubmitChanges();
         }
         return(true);
     }
     catch (Exception e)
     {
         _Logger.Error(typeof(GenericEntityType).Name + " could not be DELETED -- " + e);
         return(false);
     }
 }
Ejemplo n.º 13
0
        }//End Repository Constructor

        public OperationResult AddItem(T entity)
        {
            OperationResult opResult = OperationResult.GetInstance();

            try
            {
                GetTable.InsertOnSubmit(entity);

                this._dataContextFactory.SaveAll();
                opResult.ObjectId = PrimaryKeyName;
            }
            catch (Exception ex)
            {
                opResult.IsFailed     = true;
                opResult.ErrorMessage = ex.Message + ex.StackTrace;
            }
            return(opResult);
        }
 /// <summary>
 /// Add the entity to DB
 /// </summary>
 /// <param name="entity">DB entity</param>
 /// <returns>bool</returns>
 public bool Add(GenericEntityType entity)
 {
     if (entity == null)
     {
         _Logger.Error(typeof(GenericEntityType).Name + " is null to ADD!");
         return(false);
     }
     try
     {
         GetTable.InsertOnSubmit(entity);
         if (_Flag)
         {
             _DataContext.SubmitChanges();
         }
         return(true);
     }
     catch (Exception e)
     {
         _Logger.Error(typeof(GenericEntityType).Name + " could not be ADDED -- " + e);
         return(false);
     }
 }
        /// <summary>
        /// Pick Object by oid
        /// </summary>
        /// <param name="entity">DB entity</param>
        /// <returns>bool</returns>
        public GenericEntityType PickByID(int id)
        {
            if (id > 0)
            {
                try
                {
                    // this.DataContext.DeferredLoadingEnabled = false;
                    return(GetTable.SingleOrDefault(GetIDSelector(id)));
                }
                catch (ArgumentNullException e)
                {
                    _Logger.Error(typeof(GenericEntityType).Name + " object could not be PICKED -- " + e);
                    return(null);
                }
                catch (InvalidOperationException e)
                {
                    _Logger.Error(typeof(GenericEntityType).Name + " object could not be PICKED -- " + e);
                    return(null);
                }
            }

            return(null);
        }
 public void MarkForDeletion(T entity)
 {
     GetTable.DeleteOnSubmit(entity);
 }
 public T First(Func <T, bool> expression)
 {
     return(GetTable.First(expression));
 }
 public T Single(Func <T, bool> expression)
 {
     return(GetTable.Single(expression));
 }
 public IEnumerable <T> FindAll(Func <T, bool> expression)
 {
     return(GetTable.Where(expression));
 }
Ejemplo n.º 20
0
 private void ImportDataTableInDb(ref DataTable dataTableImportable, GetTable callGetTableImportableTemplate)
 {
     if (_importer == null) this.InitializeImporter();
     _importer.UploadTableInSqlServer(dataTableImportable, _connectionString);
     dataTableImportable.Dispose();
     dataTableImportable = callGetTableImportableTemplate();
     GC.Collect();
 }
 /// <summary>See IGenericRepository.</summary>
 /// <param name="exp"></param><returns></returns>
 public T First(Func <T, bool> exp)
 {
     return(GetTable.First(exp));
 }
 /// <summary>
 /// Return all instances of type T that match the expression exp.
 /// </summary>
 /// <param name="exp"></param>
 /// <returns></returns>
 public IEnumerable <T> FindAll(Func <T, bool> exp)
 {
     return(GetTable.Where <T>(exp));
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Inserts the specified obj.
 /// </summary>
 /// <param name="obj">The obj.</param>
 public void Insert(T obj)
 {
     GetTable.InsertOnSubmit(obj);
 }
Ejemplo n.º 24
0
 public IQueryable <T> All()
 {
     return(GetTable.AsQueryable());
 }
Ejemplo n.º 25
0
 public void Update(T entity)
 {
     GetTable.Attach(entity, true);
     SaveAll();
 }
Ejemplo n.º 26
0
        internal void GetModels(SqlConnection connection, GetTable cbGetTable)
        {
            var models = cbGetTable(connection, GetSqlStatement());

            ConvertTabelToList(models);
        }
 public void Create(T entity)
 {
     GetTable.InsertOnSubmit(entity);
 }
 /// <summary>See IGenericRepository.</summary>
 /// <param name="exp"></param><returns></returns>
 public T Single(Func <T, bool> exp)
 {
     return(GetTable.Single(exp));
 }
 public void Delete(T entity)
 {
     GetTable.DeleteOnSubmit(entity);
 }
Ejemplo n.º 30
0
 public IQueryable <T> FindAll(Func <T, bool> exp)
 {
     return(GetTable.Where <T>(exp).AsQueryable());
 }
 public IQueryable <T> FindByCondition(Expression <Func <T, bool> > expression)
 {
     return(GetTable.Where <T>(expression));
 }