This file contains hidden or 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
ALTER FUNCTION [dbo].[fn_StringSplit] | |
( | |
@Str varchar(MAX), | |
@Delimeter char(1), | |
@Position int | |
) | |
RETURNS varchar(MAX) | |
AS | |
BEGIN | |
DECLARE @T TABLE(Id int NOT NULL identity(1,1), [Value] varchar(MAX)); |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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
-- replace MYSERVER, MYDB, MYUSER, MYPASSWORD with real values | |
EXEC sp_addlinkedserver | |
@server='azure', | |
@srvproduct='', | |
@provider='sqlncli', | |
@datasrc='MYSERVER.database.windows.net', | |
@location='', | |
@provstr='', | |
@catalog='MYDB' |
This file contains hidden or 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 (var context = new BloggingContext()) | |
{ | |
try | |
{ | |
context.Configuration.AutoDetectChangesEnabled = false; | |
// Make many calls in a loop | |
foreach (var blog in aLotOfBlogs) | |
{ | |
context.Blogs.Add(blog); |
This file contains hidden or 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].[fn_cc2RemoveNonAlphaCharacters](@Temp VarChar(1000)) | |
Returns VarChar(1000) | |
AS | |
Begin | |
While PatIndex('%[^a-z]%', @Temp) > 0 | |
Set @Temp = Stuff(@Temp, PatIndex('%[^a-z]%', @Temp), 1, '') | |
Return @TEmp | |
End |
This file contains hidden or 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
--Взято отсюда http://www.sql.ru/forum/546853-2/est-li-u-kogo-gotovaya-funkciya-perevoda-translit-s-ruskogo-na-angliyskiy с небольшой корректировкой | |
ALTER FUNCTION [dbo].[fn_cc2ToTranslit] (@name NVARCHAR(MAX)) | |
RETURNS NVARCHAR(MAX) | |
BEGIN | |
DECLARE @TransTable TABLE( | |
Rus Char PRIMARY KEY | |
,Lat VarChar(2) | |
)INSERT @TransTable SELECT 'А','A' | |
UNION ALL SELECT 'Б','B' |
This file contains hidden or 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
protected string RenderRazorViewToString(string viewName, object model) | |
{ | |
ViewData.Model = model; | |
using (var sw = new StringWriter()) { | |
var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName); | |
var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw); | |
viewResult.View.Render(viewContext, sw); | |
viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View); | |
return sw.GetStringBuilder().ToString(); | |
} |
This file contains hidden or 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
private static void RegisterServices(IKernel kernel) | |
{ | |
kernel.Bind<MyDbContext>().ToSelf().InRequestScope(); | |
} |
This file contains hidden or 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
rmdir /s /q C:\wwwroot\MyAdmin\App_data |
This file contains hidden or 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
from project in _db.Projects | |
join typeOfficial in _db.GuidContents on (short?)project.TypeOfficial equals typeOfficial.Value into TtypeOfficial | |
from typeOfficial in TtypeOfficial.DefaultIfEmpty() | |
where typeOfficial.Guid == 1 | |
join typePanel in _db.GuidContents on (short?)project.TypePanel equals typePanel.Value into TtypePanel | |
from typePanel in TtypePanel.DefaultIfEmpty() | |
where typePanel.Guid == 2 | |
join status in _db.GuidContents on (short?)project.StatusId equals status.Value into TStatus | |
from status in TStatus.DefaultIfEmpty() | |
where status.Guid == 3 |