cascading-deletes

My 'ON DELETE CASCADE ' does not work

无人久伴 提交于 2019-12-20 04:51:13
问题 I have got 3 tables: lt_hdefaults , lt_hperiods and lt_hrules . In lt_hdefaults , there is one row for a property for a particular year. In the lt_hperiods table, there could be more than one period, call them seasons. In the lt_hrules table, there could be more than one rule for each period. Now, what I could not make work: when the user deletes a record from lt_hdefaults , other data related to the deleted record should be removed from lt_hperiods and lt_hrules table. I am trying to achieve

C# - Predict file system events on folder delete

房东的猫 提交于 2019-12-19 19:47:16
问题 This is more a question about what's the best practice in implementing this. I have a FileSystemWatcher which should inform me about User's changes on files and folders. Also subdirs are watched. In the same directory my program does also sometimes changes. I don't want the FileSystemWatcher to detect events on these program changes. My first implementation was a list where I can add expected events. When I get a file system event I check the list and ignore it if it's there. This doesn't

EF 4.1 RC: Weird Cascade Delete

蹲街弑〆低调 提交于 2019-12-19 03:39:17
问题 I have to admit, the features of EF 4.1 RC Codefirst, DataAnnotations and FluentAPI are still overwhelming to me. Sometimes I really don't know what I am doing ;-) Please see the following POCOs: public class Country { [Key] public Guid ID { get; set; } [Required] public virtual Currency Currency { get; set; } } public class Currency { [Key] public Guid ID { get; set; } public virtual ICollection<Country> Countries { get; set; } } The general idea: Every country needs to have a currency. But

Entity Framework object graph deletion with Breeze

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 09:41:26
问题 I am encountering a recurring problem that just makes no sense, and hoping someone (in the Breeze team?) can shed some light. The following model illustrates the entities in question. As you can see, I'm adhering pretty strictly to Entity Framework conventions in my property names, and as a result, if I check in SQL the cascade on delete rules are set by EF code first when it creates the db. Now, when I try to delete a BusUnit manually in SQL, the delete cascades correctly and the

Cascading deletes with Entity Framework - Related entities deleted by EF

送分小仙女□ 提交于 2019-12-17 05:01:41
问题 I have an issue with deletion in Entity Framework. In short, EF explicitly tries to delete an entity from the database even though I've explcitly configured EF to use cascading deletes in the database. My design: I have three entity types, MainEntity , EntityTypeA and EntityTypeB . EF has been configured to use cascade deletion when deleting EntityTypeA and EntityTypeB . In other words, if I delete an instance of MainEntity , I want all related EntityTypeA and EntityTypeB instances to be

On delete cascade with doctrine2

那年仲夏 提交于 2019-12-17 02:19:32
问题 I'm trying to make a simple example in order to learn how to delete a row from a parent table and automatically delete the matching rows in the child table using Doctrine2. Here are the two entities I'm using: Child.php: <?php namespace Acme\CascadeBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="child") */ class Child { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\ManyToOne(targetEntity=

How do I use cascade delete with SQL Server?

点点圈 提交于 2019-12-16 19:30:26
问题 I have 2 tables: T1 and T2, they are existing tables with data. We have a one to many relationship between T1 and T2. How do I alter the table definitions to perform cascading delete in SQL Server when a record from T1 is deleted, all associated records in T2 also deleted. The foreign constraint is in place between them. I don't want to drop the tables or create a trigger to do the deletion for T2. For example, when I delete an employee, all the review record should be gone, too. T1 -

On delete cascade - where I have to add it

拜拜、爱过 提交于 2019-12-14 02:47:38
问题 I needed an example of cascade delete. My question is, where do I add it? In the table I create PK, or in other tables where this PK is sitting there as FK? Can I use "alter table" to add "on delete cascade" to existing table? An example please? @edit MYSQL, using phpMyAdmin @edit 2 Does it look good? alter table wplaty drop foreign key pesel, add constraint pesel foreign key (pesel) references baza_osob(pesel) on delete cascade on update restrict; My parent table = baza_osob My child table =

Cascade Deleting Many-To-Many relationship in entity framework

前提是你 提交于 2019-12-13 06:50:00
问题 I have three tables in my database: Articles: ArticleID (PK) Tags: TagiID (PK) ArticleTagMapping: ArticleID(FK,PK), TagID(FK,PK) ArticleTagMapping has a composite primary key. This resulted in a many-to-many relationship in my entity model as expected. I have set both the foreign key relationships to cascade on delete in database. I am trying to delete Article via C# code. This errors out... var ArticleToDelete = context.Articles.SingleOrDefault(x => x.ArticleID == ArticleID); context

Replace T-SQL triggers with Entity Framework 4.0 code?

雨燕双飞 提交于 2019-12-13 04:17:02
问题 Entity Framework 4.0 project. I am currently doing my cascading deletes using an INSTEAD OF DELETE trigger. Is there a way to just do this in my Data Model code? I thought about adding my Data Context class via partial class. Then using ObjectStateManager.ObjectStateManagerChanged to watch for deletes, and then delete children first. The problem is that will partial I can't hook into constructor to make sure my event gets hooked up. I guess I could make a factory method that created the