Skip to main content

Posts

Showing posts from April, 2019

Override AccessTokenExpireTimeSpan - Session Expire too early

You have to set the expiration time in the  TokenEndPoint  method instead of  GrantResourceOwnerCredentials  method: public override Task TokenEndpoint(OAuthTokenEndpointContext context) { ... if (condition) { context.Properties.ExpiresUtc = DateTime.UtcNow.AddDays(14); } ... } Ref:  https://stackoverflow.com/questions/32120754/override-accesstokenexpiretimespan

SQL Server replace, remove all after certain character

Use LEFT combined with CHARINDEX: UPDATE MyTable SET MyText = LEFT ( MyText , CHARINDEX ( ';' , MyText ) - 1 ) WHERE CHARINDEX ( ';' , MyText ) > 0 Note that the WHERE clause skips updating rows in which there is no semicolon. Here is some code to verify the SQL above works: declare @ MyTable table ([ id ] int primary key clustered , MyText varchar ( 100 )) insert into @ MyTable ([ id ], MyText ) select 1 , 'some text; some more text' union all select 2 , 'text again; even more text' union all select 3 , 'text without a semicolon' union all select 4 , null -- test NULLs union all select 5 , '' -- test empty string union all select 6 , 'test 3 semicolons; second part; third part;' union all select 7 , ';' -- test semicolon by itself UPDATE @ MyTable SET MyText = LEFT ( MyText , CHARINDEX ( ';' , MyText ) - 1 ) WHERE CHARINDEX ( '