Link to home
Start Free TrialLog in
Avatar of Hoboly
Hoboly

asked on

what is the right/best way to pass context_info and use context_info in trigger in entity framework?

I have a stored prod to set context_info
I have a stored prod to get context_info
I have a trigger to use the saved  context_info
works very well in sql server management studio

However, when I use the 2 stored prod in entity framework.
1. set context_info
2. update some records
3.  savechanges
The trigger can't get the saved context_info at all.

When I check sql profiles, there are sp_reset_connection in between.
will it affect?

what is the right/best way to pass context_info and use context_info in trigger in entity framework?

Thanks!

ALTER procedure [dbo].[set_context_info] @var varchar(255) as 

--declare @var varchar(50);
--set @var = 'UT;SPABIY;1234567890123456789012345678901234567890';
declare @binvar binary(128);
set @binvar = convert(binary(128),@var);
set context_info @binvar;








ALTER procedure [dbo].[get_context_info] 
as

declare @bincontext_info binary(128);
declare @context_info varchar(50);
declare @temp_output varchar(50);
declare @temp varchar(50);
declare @user varchar(50);
declare @tx_key bigint;
							
							
set @bincontext_info = context_info() ;
set @context_info = convert(varchar(50), @bincontext_info);

set @temp_output = 'context_info: ' + @context_info
raiserror(@temp_output ,10,1);--temp 10, 1

Open in new window

SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hoboly
Hoboly

ASKER

Thanks to HainKurt anyway