Skip to content

Instantly share code, notes, and snippets.

View the-tatarinov-av's full-sized avatar

Alexander Tatarinov the-tatarinov-av

  • Serenity, LLC
  • Yoshkar-Ola
View GitHub Profile
@the-tatarinov-av
the-tatarinov-av / gist:2eb519e1ed4bb14dbc6f41756d485bd4
Created December 25, 2017 14:08
SQL Server Index Naming Conventions
PK_ for primary keys
UK_ for unique keys
IX_ for non clustered non unique indexes
UX_ for unique indexes
All of my index name take the form of
<index or key type>_<table name>_<column 1>_<column 2>_<column n>
$folder = $args[0]
$configuration = $args[1]
$xunit = $args[2]
$testType = $args[3]
$service = $args[4]
$category = $args[5]
try
{
Start-Transcript -Path C:\output.txt -Append
public static class TaskExtensions
{
public static Task Catch(this Task task, Action<Exception> exceptionHandler)
{
return task.ContinueWith(t =>
{
if (t.IsCanceled || !t.IsFaulted || exceptionHandler == null)
{
return;
}
//Create a CTS to launch a task in charge of renewing the message lock
var brokeredMessageRenewCancellationTokenSource = new CancellationTokenSource();
try
{
var brokeredMessage = _client.Receive();
var brokeredMessageRenew = Task.Factory.StartNew(() =>
{
while (!brokeredMessageRenewCancellationTokenSource.Token.IsCancellationRequested)
@the-tatarinov-av
the-tatarinov-av / MessageLock
Created April 5, 2017 09:43 — forked from Soopster/MessageLock
Message Lock Renewal For Azure Service Bus Brokered Messages
private async Task OnMessageReceivedAsync(BrokeredMessage receivedMessage)
{
try{
var messageLock = new MessageLock(receivedMessage)){
// Process receivedMessage
await messageLock.CompleteAsync();
}
finally {
messageLock.Dispose();
public IEnumerable<SendMailRequestBackoffice> BuildQuery(int statusId, int isSpam, string advertId, int sourceSite,
int destSite, string dateFrom, string dateTo, string textSearch)
{
var requests = DbContext.SendMailRequests.Where(req => req.StatusId == statusId && req.IsSpam == isSpam);
if (sourceSite != 0)
{
requests = requests.Where(req => req.SrcSiteId == sourceSite);
}
WITH SubTree (Id, ParentId, Branch)
AS (
SELECT Id, ParentId, 1 AS Branch
FROM Subdivisions
WHERE Id = 146000
UNION ALL
SELECT s.Id, s.ParentId, t.Branch + 1 AS Branch
FROM Subdivisions s
JOIN SubTree t ON t.ParentId = s.Id
)