kommissar
kommissar
CC#
Created by kommissar on 2/6/2023 in #help
Entity Framework - DbUpdateConcurrencyException due to a trigger on the table
USE [Dev]
GO
/****** Object: Trigger [dbo].[tr_route_cards_update] Script Date: 06/02/2023 09:03:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tr_route_cards_update] ON [dbo].[route_cards]
AFTER UPDATE
AS
BEGIN
IF UPDATE(part_num) OR UPDATE(issue) OR UPDATE(batch_qty) OR UPDATE(qty_finished) OR UPDATE(qty_rejected) OR
UPDATE(route_status) OR UPDATE(inspected) OR UPDATE(sign_off)
BEGIN
DECLARE @old_qty_rejected NUMERIC(19,7);
DECLARE @new_qty_finished NUMERIC(19,7);
DECLARE @new_qty_rejected NUMERIC(19,7);
DECLARE @new_batch_qty INTEGER;
DECLARE @new_part_num NVARCHAR(36);
DECLARE @new_part_issue NVARCHAR(10);
DECLARE @route_date DATETIME;
DECLARE @contract_no INTEGER;
DECLARE @top_level_part NVARCHAR(36);
DECLARE @top_level_issue NVARCHAR(10);

SELECT @new_qty_finished = COALESCE(qty_finished, 0)
,@new_batch_qty = batch_qty
,@new_part_num = part_num
,@new_part_issue = issue
,@top_level_part = top_level_part
,@top_level_issue = top_level_issue
,@contract_no = contract_no
FROM inserted;
SET @new_qty_rejected = 0;

-- part last order details update
UPDATE parts
SET last_order_date = GETDATE()
,last_order_qty = @new_qty_finished - @new_qty_rejected
,lead_time = DATEDIFF(dd, @route_date, GETDATE())
WHERE parts.part_num = @new_part_num
AND parts.issue = @new_part_issue;

IF @contract_no is not null AND @contract_no > 0 AND @top_level_part = @new_part_num AND @top_level_issue = @new_part_issue
execute sp_contract_update_qty_info @contract_no;
END;
END;
USE [Dev]
GO
/****** Object: Trigger [dbo].[tr_route_cards_update] Script Date: 06/02/2023 09:03:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tr_route_cards_update] ON [dbo].[route_cards]
AFTER UPDATE
AS
BEGIN
IF UPDATE(part_num) OR UPDATE(issue) OR UPDATE(batch_qty) OR UPDATE(qty_finished) OR UPDATE(qty_rejected) OR
UPDATE(route_status) OR UPDATE(inspected) OR UPDATE(sign_off)
BEGIN
DECLARE @old_qty_rejected NUMERIC(19,7);
DECLARE @new_qty_finished NUMERIC(19,7);
DECLARE @new_qty_rejected NUMERIC(19,7);
DECLARE @new_batch_qty INTEGER;
DECLARE @new_part_num NVARCHAR(36);
DECLARE @new_part_issue NVARCHAR(10);
DECLARE @route_date DATETIME;
DECLARE @contract_no INTEGER;
DECLARE @top_level_part NVARCHAR(36);
DECLARE @top_level_issue NVARCHAR(10);

SELECT @new_qty_finished = COALESCE(qty_finished, 0)
,@new_batch_qty = batch_qty
,@new_part_num = part_num
,@new_part_issue = issue
,@top_level_part = top_level_part
,@top_level_issue = top_level_issue
,@contract_no = contract_no
FROM inserted;
SET @new_qty_rejected = 0;

-- part last order details update
UPDATE parts
SET last_order_date = GETDATE()
,last_order_qty = @new_qty_finished - @new_qty_rejected
,lead_time = DATEDIFF(dd, @route_date, GETDATE())
WHERE parts.part_num = @new_part_num
AND parts.issue = @new_part_issue;

IF @contract_no is not null AND @contract_no > 0 AND @top_level_part = @new_part_num AND @top_level_issue = @new_part_issue
execute sp_contract_update_qty_info @contract_no;
END;
END;
15 replies
CC#
Created by kommissar on 2/6/2023 in #help
Entity Framework - DbUpdateConcurrencyException due to a trigger on the table
there is a trigger on the table that updates a bunch of stuff, but not this particular table
15 replies
CC#
Created by kommissar on 2/6/2023 in #help
Entity Framework - DbUpdateConcurrencyException due to a trigger on the table
Thing is when I remove the triggers it works
15 replies
CC#
Created by kommissar on 2/6/2023 in #help
Entity Framework - DbUpdateConcurrencyException due to a trigger on the table
15 replies
CC#
Created by kommissar on 2/6/2023 in #help
Entity Framework - DbUpdateConcurrencyException due to a trigger on the table
nope, definitely not. Checked numerous times.
15 replies
CC#
Created by kommissar on 2/6/2023 in #help
Entity Framework - DbUpdateConcurrencyException due to a trigger on the table
If it does not enter the if statement, it's always fine.
15 replies
CC#
Created by kommissar on 2/6/2023 in #help
Entity Framework - DbUpdateConcurrencyException due to a trigger on the table
actually it's only when it enters the if statement.
15 replies
CC#
Created by kommissar on 2/6/2023 in #help
Serialising and deserialising json derived file
I think I need to do some trial and error because honestly I'm not following. Thank you for your help though, and I won't bother you anymore because clearly I need to do some reading to understand the subject better rather than to waste people's time 😉 Basically I'm trying to make a modding tool for Rome Total War Remastered, where game / mod files can be deserialised into GUI objects, that can be edited and then serialised back into this format so that the game can read them. It's funny that I managed to release relatively successful games on Steam, but can't deal with simple serialisation issue 🙂
24 replies
CC#
Created by kommissar on 2/6/2023 in #help
Serialising and deserialising json derived file
also if I have names for objects like "romans_julii" and "macedon" - how to handle those? They are essentially the class types.
24 replies
CC#
Created by kommissar on 2/6/2023 in #help
Serialising and deserialising json derived file
I serialised and deserialised objects before for my game, but this is something different 😄
24 replies
CC#
Created by kommissar on 2/6/2023 in #help
Serialising and deserialising json derived file
I think I'm going to write a parser because there are so many weird variables I don't know how to handle that it might be easier 😅
24 replies
CC#
Created by kommissar on 2/6/2023 in #help
Serialising and deserialising json derived file
What can I do with the name of properties such as "string" though? Sorry I'm a little new to deserialising objects.
24 replies
CC#
Created by kommissar on 2/6/2023 in #help
Serialising and deserialising json derived file
It's internally called quasi-json, the main difference is that we assume an enclosing object (i.e. the first element does not have to be an object or array opening brace) and all key-value pairs MUST be ended by a comma (as opposed to true JSON where the last one in an object explicitly cannot)
24 replies