Пример #1
0
        public void DeleteGenerator_EntityType_Valid()
        {
            var sql      = generator.GenerateDelete <Product>(x => x.Price > 5, out IList <QueryInfo> queryParameters);
            var expected = "DELETE FROM `Product` WHERE `Price` > @Price;";

            Assert.AreEqual(expected, sql);
            Assert.AreEqual(5, queryParameters.First(x => x.ParameterName == "Price").PropertyValue);
        }
Пример #2
0
        public virtual int DoDelete <T>(T entity, Func <T, bool> resultAction = null) where T : class
        {
            TryGetFromCache(out string query, out IList <QueryInfo> queryParameters);
            query = query ?? _queryGenerator.GenerateDelete(entity, out queryParameters);
            TrySetCache(query, queryParameters);
            var cmd = new DotEntityDbCommand(DbOperationType.Delete, query, queryParameters);

            DotEntityDbConnector.ExecuteCommand(cmd);
            return(cmd.GetResultAs <int>());
        }