Esempio n. 1
0
        public int Delete <T>(object propertyValue, string propertyName) where T : class
        {
            EntitySet entitySet = DbContextExtensions.GetEntitySet <T>(dbcontext);

            if (entitySet != null)
            {
                string tableName = entitySet.MetadataProperties.Contains("Table") && entitySet.MetadataProperties["Table"].Value != null
                               ? entitySet.MetadataProperties["Table"].Value.ToString()
                               : entitySet.Name;
                return(this.ExecuteBySql(DbContextExtensions.DeleteSql(tableName, propertyName, propertyValue)));
            }
            return(-1);
        }
Esempio n. 2
0
        public int Delete <T>(object[] keyValue) where T : class
        {
            EntitySet entitySet = DbContextExtensions.GetEntitySet <T>(dbcontext);

            if (entitySet != null)
            {
                string tableName = entitySet.MetadataProperties.Contains("Table") && entitySet.MetadataProperties["Table"].Value != null
                               ? entitySet.MetadataProperties["Table"].Value.ToString()
                               : entitySet.Name;
                string keyFlied = entitySet.ElementType.KeyMembers[0].Name;
                return(this.ExecuteBySql(DbContextExtensions.DeleteSql(tableName, keyFlied, keyValue)));
            }
            return(-1);
        }
Esempio n. 3
0
        public int Delete <T>(object[] keyValue) where T : class
        {
            EntitySet entitySet = DbContextExtensions.GetEntitySet <T>(dbcontext);

            if (entitySet != null)
            {
                string schema = (entitySet.MetadataProperties.Contains("Schema") && entitySet.MetadataProperties["Schema"].Value != null)
                                ? entitySet.MetadataProperties["Schema"].Value.ToString()
                                : "";
                string tableName = (entitySet.MetadataProperties.Contains("Table") && entitySet.MetadataProperties["Table"].Value != null)
                                   ? entitySet.MetadataProperties["Table"].Value.ToString()
                                   : entitySet.Name;
                string fullName = string.IsNullOrEmpty(schema) ? tableName : (schema + "." + tableName);
                string keyFlied = entitySet.ElementType.KeyMembers[0].Name;
                return(this.ExecuteBySql(DbContextExtensions.DeleteSql(fullName, keyFlied, keyValue)));
            }
            return(-1);
        }