Код: Выделить всё
Table Product
(
DateOf date not null,
Type varchar(100) not null,
ProductId int not null,
ProductCategory varchar(100) not null
Primary Key (DateOf,Type)
)
Table ProductListing
(
DateOf date not null,
Type varchar(100) not null,
RowId int identity(1,1) not null,
Quantity int not null,
Primary key(DateOf,Type,RowId)
Foreign key (DateOf,Type) references Product (DateOf,Type)
)
У меня есть код EF, например, предполагая пользователь передает параметры даты и категории
Код: Выделить всё
dbContext.Product.Where(p=> p.DateOf = date && p.ProductCategory = category).ExecuteDelete()
Код: Выделить всё
Delete pl from
ProductListing pl
inner join Product p on p.DateOf=pl.DateOf and p.Type=pl.Type -- join on foreign key
where
-- below are the parameters passed by user
p.DateOf = date
and p.ProductCategory = category
Я не уверен, как заставить ядро Entity Framework создать такой оператор удаления. Обратите внимание, что приведенный выше оператор удаления необходим, поскольку количество записей огромно, и этот единственный оператор обеспечивает удаление одним оператором.
Обратите внимание, что каскадное удаление таблицы невозможно добавить из-за причины устаревших данных.
Подробнее здесь: https://stackoverflow.com/questions/784 ... es-without