Generate sql script using c# code

class Program { static void Main(string[] args) { string dbConnectionString = “Server=./sqlexpress;Database=mydata;User ID=sa;Password=test@111;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;”; string databaseName = “mydata”; ScriptDatabase(dbConnectionString, databaseName); } public static string ScriptDatabase(string dbConnectionString, string databaseName) { SqlConnection conn = new SqlConnection(dbConnectionString); ServerConnection serverConn = new ServerConnection(conn); var server = new Server(serverConn); var database = server.Databases[databaseName]; var scripter = new Scripter(server); /* With… Read More Generate sql script using c# code

execute sql script c# code

public void Execute(string sqlfilePath) { string dbConnectionString = “”; try { using (StreamReader file = new StreamReader(filePath)) using (SqlConnection conn = new SqlConnection(dbConnectionString)) { StringBuilder sql = new StringBuilder(); string line; while ((line = file.ReadLine()) != null) { // replace GO with semi-colon if (line == “GO”) sql.Append(“;”); // remove inline comments else if (line.IndexOf(“–“)… Read More execute sql script c# code

create user to azure ad   services platforms author active-directory dotnet dstrockis Build a multi-tenant SaaS web application using Azure AD & OpenID Connect This sample shows how to build a multi-tenant .Net MVC web application that uses OpenID Connect to sign up and sign in users from any Azure Active Directory tenant, using the ASP.Net OpenID Connect OWIN… Read More create user to azure ad

global nuget directory

create nuget.config file <?xml version=”1.0″ encoding=”utf-8″?> <configuration> <config> <add key=”repositoryPath” value=”C:\Nuget Packages” /> </config> </configuration> copy this file to Solution Directory open notepad++ and find and replace text below find – ..\packages replace with – C:\Nuget Packages filters – *.csproj click find and replace button it will replace references . create folder C:\Nuget Packages Done! Build solution all nuget… Read More global nuget directory

Get version from request header

private string GetVersionFromAcceptHeaderVersion(HttpRequestMessage request) { string temp = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “Controllers”); if (System.Web.HttpContext.Current.Request.Headers[“X-Api-Version”] != null) { IEnumerable<string> headerValues = request.Headers.GetValues(“X-Api-Version”); if (headerValues != null) { return headerValues.FirstOrDefault(); } return string.Empty; } else { var latestversion = Directory.GetDirectories(temp) .OrderByDescending(dir => dir) .FirstOrDefault(); return latestversion.Substring(latestversion.Length – 1); } }