public void DeleteByKey(int employeeKey)
 {
     using (var adapter = new DataAccessAdapter())
     {
         adapter.DeleteEntitiesDirectly(typeof(EmployeeEntity), new RelationPredicateBucket(EmployeeFields.EmployeeKey.Equal(employeeKey)));
     }
 }
Exemplo n.º 2
0
 protected override void DeleteInserted(IEnumerable <CreditCardEntity> toDelete)
 {
     using (var adapter = new DataAccessAdapter())
     {
         adapter.DeleteEntitiesDirectly(typeof(CreditCardEntity), new RelationPredicateBucket(CreditCardFields.CreditCardId.GreaterThan(19237)));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Deletes the person by identifier directly using predicate bucket.
 /// </summary>
 /// <param name="businessEntityId">The business entity identifier.</param>
 public static void DeletePersonByIdDirectlyUsingPredicateBucket(int businessEntityId)
 {
     using (var adapter = new DataAccessAdapter())
     {
         RelationPredicateBucket filterBucket = new RelationPredicateBucket(PersonFields.BusinessEntityId == businessEntityId);
         adapter.DeleteEntitiesDirectly(typeof(PersonEntity), filterBucket);
     }
 }
Exemplo n.º 4
0
 public void Delete(int departmentKey)
 {
     using (var adapter = new DataAccessAdapter())
     {
         // delete directly on the DB, no fetch
         adapter.DeleteEntitiesDirectly(typeof(DepartmentEntity), new RelationPredicateBucket(DepartmentFields.DepartmentKey == departmentKey));
     }
 }
 public void Delete(int employeeClassificationKey)
 {
     using (var adapter = new DataAccessAdapter())
     {
         // delete directly from the Database, no need to fetch it first.
         adapter.DeleteEntitiesDirectly(typeof(EmployeeClassificationEntity),
                                        new RelationPredicateBucket(EmployeeClassificationFields.EmployeeClassificationKey == employeeClassificationKey));
     }
 }
        public static int Delete(Guid templateguid)
        {
            DataAccessAdapter   ds   = new DataAccessAdapter();
            PredicateExpression pred = new PredicateExpression();

            pred.Add(TemplateChunksFields.TemplateGUID == templateguid);
            RelationPredicateBucket bucket = new RelationPredicateBucket(pred);

            return(ds.DeleteEntitiesDirectly("TemplateChunksEntity", bucket));
        }
Exemplo n.º 7
0
 public virtual void DeleteByKey(int employeeClassificationKey)
 {
     using (var adapter = new DataAccessAdapter())
     {
         // delete directly, so we don't have to fetch the entity first.
         adapter.DeleteEntitiesDirectly(typeof(EmployeeClassificationEntity),
                                        new RelationPredicateBucket(EmployeeClassificationFields.EmployeeClassificationKey
                                                                    .Equal(employeeClassificationKey)));
     }
 }
Exemplo n.º 8
0
        public static bool Delete(Type type, IRelationPredicateBucket filter)
        {
            bool result = false;

            using (DataAccessAdapterBase dataAccessAdapterBase = new DataAccessAdapter(ManageBase.ConnectionString))
            {
                result = (dataAccessAdapterBase.DeleteEntitiesDirectly(type, filter) > 0);
            }
            return(result);
        }
Exemplo n.º 9
0
 public bool DeleteByKeyWithStatus(int employeeClassificationKey)
 {
     using (var adapter = new DataAccessAdapter())
     {
         // delete directly
         int count = adapter.DeleteEntitiesDirectly(typeof(EmployeeClassificationEntity),
                                                    new RelationPredicateBucket(EmployeeClassificationFields.EmployeeClassificationKey
                                                                                .Equal(employeeClassificationKey)));
         return(count > 0);
     }
 }
Exemplo n.º 10
0
        public static bool DeleteThongTinHoSo(long thongTinHoSoId)
        {
            bool result = false;

            using (DataAccessAdapterBase dataAccessAdapterBase = new DataAccessAdapter(ManageBase.ConnectionString))
            {
                RelationPredicateBucket relationPredicateBucket = new RelationPredicateBucket();
                relationPredicateBucket.PredicateExpression.Add(ThongTinHoSoFields.ThongTinHoSoId == thongTinHoSoId);
                result = (dataAccessAdapterBase.DeleteEntitiesDirectly(typeof(ThongTinHoSoEntity), relationPredicateBucket) > 0);
            }
            return(result);
        }
Exemplo n.º 11
0
        public static bool DeleteNguoiDung(int nguoiDungId)
        {
            bool result = false;

            using (DataAccessAdapterBase dataAccessAdapterBase = new DataAccessAdapter(ManageBase.ConnectionString))
            {
                RelationPredicateBucket relationPredicateBucket = new RelationPredicateBucket();
                relationPredicateBucket.PredicateExpression.Add(NguoiDungFields.NguoiDungId == nguoiDungId);
                result = (dataAccessAdapterBase.DeleteEntitiesDirectly(typeof(NguoiDungEntity), relationPredicateBucket) > 0);
            }
            return(result);
        }
Exemplo n.º 12
0
        public static int DeleteByCondition(IRelationPredicateBucket filter)
        {
            int         toReturn    = 0;
            TEntity     _entity     = (TEntity)Activator.CreateInstance(typeof(TEntity));
            IEntityCore _entityCore = (IEntityCore)_entity;

            using (DataAccessAdapter adapter = DataAccessAdapterManagerBase.CreateAdapter())
            {
                toReturn = adapter.DeleteEntitiesDirectly(_entityCore.LLBLGenProEntityName, filter);
            }
            return(toReturn);
        }
Exemplo n.º 13
0
        public void DeleteBatchByKey(IList <int> employeeKeys)
        {
            if (employeeKeys == null || employeeKeys.Count == 0)
            {
                throw new ArgumentException($"{nameof(employeeKeys)} is null or empty.", nameof(employeeKeys));
            }

            using (var adapter = new DataAccessAdapter())
            {
                // Delete the entities directly using an IN (key1, key2...) predicate.
                adapter.DeleteEntitiesDirectly(typeof(EmployeeEntity),
                                               new RelationPredicateBucket(EmployeeFields.EmployeeKey.In(employeeKeys)));
            }
        }
Exemplo n.º 14
0
 public void DeleteByKeyOrException(int employeeClassificationKey)
 {
     using (var adapter = new DataAccessAdapter())
     {
         // delete directly
         int count = adapter.DeleteEntitiesDirectly(typeof(EmployeeClassificationEntity),
                                                    new RelationPredicateBucket(EmployeeClassificationFields.EmployeeClassificationKey
                                                                                .Equal(employeeClassificationKey)));
         if (count <= 0)
         {
             throw new DataException($"No row was found for key {employeeClassificationKey}.");
         }
     }
 }
        /// <summary>
        /// Handles the EntityDeleting event of the LLBLGenProDataSource.
        /// Used to delete order details related to the order being deleted.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OrdersDS_EntityDeleting(object sender, CancelableDataSourceActionEventArgs e)
        {
            //Get the Order to be deleted
            OrderEntity orderToDelete = (OrderEntity)e.InvolvedEntity;

            try
            {
                // directly delete all order details with a matching OrderId
                DataAccessAdapter adapter = new DataAccessAdapter();
                adapter.DeleteEntitiesDirectly("OrderDetailEntity", new RelationPredicateBucket(OrderDetailFields.OrderId == orderToDelete.OrderId));
            }
            // All exceptions are swallowed here, it's outside the scope of this example to handle different exceptions.
            // If you are going to use this code in production, it's a best practice to add proper exception handling.
            catch
            {
                // cancel the Order deletion, if anything wrong happened while deleting its related order-details.
                e.Cancel = true;
            }
        }