I use a SQL Procedure to update many rows in one table based on a crieteria, here a date.
CREATE PROCEDURE [S_SourceProduct].P_U_SourceProductSetDisableBeforeDate
@UpdateDate DATETIME
AS
SET NOCOUNT ON;
UPDATE [S_SourceProduct].T_E_SourceProduct
SET [Disabled]=1
WHERE [S_SourceProduct].T_E_SourceProduct.UpdateDate < @UpdateDate
I didn't do it with entity because I know only 2 ways:
- Retrieve all items and loop on each one => slower than my stored procedure with a lot of rows.
- Copy my procedure in a string and use it as string query => no build checking about syntaxe or column name and so on.
Is there an other except up both ?