Exemplo n.º 1
0
 public int ExecuteByProc(string procName, params DbParameter[] dbParameters)
 {
     if (DbTransaction == null)
     {
         return(DbContext.Database.ExecuteSqlCommand(DbContextExtensions.BuilderProc(procName), dbParameters));
     }
     return(DbTransaction == null?Commit() : 0);
 }
Exemplo n.º 2
0
        public int Delete <T>(object propertyValue, string propertyName) where T : class
        {
            var entitySet = DbContextExtensions.GetEntitySet <T>(DbContext);

            if (entitySet != null)
            {
                var tableName =
                    entitySet.MetadataProperties.Contains("Table") &&
                    entitySet.MetadataProperties["Table"].Value != null
                        ? entitySet.MetadataProperties["Table"].Value.ToString()
                        : entitySet.Name;
                return(ExecuteBySql(DbContextExtensions.DeleteSql(tableName, propertyName, propertyValue)));
            }
            return(-1);
        }
Exemplo n.º 3
0
        public int Delete <T>(object[] keyValues) where T : class
        {
            var entitySet = DbContextExtensions.GetEntitySet <T>(DbContext);

            if (entitySet != null)
            {
                var tableName =
                    entitySet.MetadataProperties.Contains("Table") &&
                    entitySet.MetadataProperties["Table"].Value != null
                        ? entitySet.MetadataProperties["Table"].Value.ToString()
                        : entitySet.Name;
                var keyField = entitySet.ElementType.KeyMembers[0].Name;
                return(ExecuteBySql(DbContextExtensions.DeleteSql(tableName, keyField, keyValues)));
            }
            return(-1);
        }