This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT T.TABLE_NAME, C.COLUMN_NAME, C.DATA_TYPE, C.IS_NULLABLE | |
INTO #Tables | |
FROM INFORMATION_SCHEMA.TABLES T | |
INNER JOIN ( | |
SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE COLUMN_NAME = TABLE_NAME + 'Id' | |
) C ON C.TABLE_NAME = T.TABLE_NAME | |
WHERE T.TABLE_TYPE = 'BASE TABLE' | |
AND T.TABLE_NAME NOT IN ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq.Expressions; | |
using System.Linq; | |
using System.Collections.Generic; | |
namespace Rvc.Utilities | |
{ | |
// refer to System.Web.Query.Dynamic namespace | |
public static class IQueryableExtensions | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rfv = document.getElementById('validator_control_id'); | |
ValidatorEnable(rfv, true); | |
ValidatorEnable(rfv, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Data XML | |
SET @Data = '<Ids> | |
<Id>64122</Id> | |
<Id>12345</Id> | |
<Id>67890</Id> | |
</Ids>' | |
SELECT Ids.Id.value('text()[1]', 'varchar(100)') | |
FROM @Data.nodes('Ids/Id') AS Ids(Id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
add those 2 services in Startup class of Identity Server 4 project. | |
services.AddTransient<ITokenService, TokenService>() | |
.AddTransient<ITokenCreationService, TokenCreationService>(); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add IdentityModel.AspNetCore package | |
using Microsoft.Extensions.DependencyInjection; | |
using IdentityModel.Client; | |
public class Startup | |
{ | |
/* removed all other code for brevity */ | |
public void ConfigureServices(IServiceCollection services) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[fnGetDateRange] | |
( | |
@Now DATETIME, | |
@FrequencyId INT | |
) | |
RETURNS @Result TABLE | |
( | |
StartDate DATE, | |
EndDate DATE | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[spDuplicateEntryWithIdentityValue] | |
@TableName NVARCHAR(128), | |
@IdentityColumnName NVARCHAR(128), -- the name of auto-increasing column | |
@CurrentIdentityValue INT, | |
@NewIdentityValue INT OUTPUT | |
AS | |
DECLARE @ColumnNames NVARCHAR(MAX) | |
SELECT @ColumnNames = STRING_AGG(N'[' + COLUMN_NAME + N']', N', ') | |
FROM INFORMATION_SCHEMA.COLUMNS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT T.name AS TableName, A.name AS ColumnName, d.name AS ConstraintName | |
FROM sys.default_constraints D | |
INNER JOIN sys.all_columns A ON A.default_object_id = D.object_id | |
INNER JOIN sys.tables T ON T.object_id = A.object_id | |
WHERE T.name = @TableName AND A.name = @ColumnName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* source: https://stackoverflow.com/a/7124052/2753545 */ | |
function htmlEscape(str) { | |
return str | |
.replace(/&/g, '&') | |
.replace(/"/g, '"') | |
.replace(/'/g, ''') | |
.replace(/</g, '<') | |
.replace(/>/g, '>') | |
.replace(/\//g, '/'); |