GenesysFramework.com
RSS

Blog posts tagged with 'c#'

$”” string interpolation condenses .NET string.Format()
String interpolation is available via dollar sign $, and it makes code much more readable. For example: var dateMessage = $"Current date is: {DateTime.UtcNow}"; Or a more in-depth example, unrolling SqlParameter nvarchar values foreach (var item in Parameters) { var commaSeparator = sqlStatement.Contains("@") ? "," : ""; sqlStatement = $"{sqlStatement}{commaSeparator} {item.ParameterName} = '{item.Value}'"; } Happy Coding!
Disallow in prod: alert() and response.write debugging

JS still requires a lot of alert() debugging. A quickie technique to stop that code from bleeding into Dev/qa/prod:

Put this in your _layout.cshtml or window.onload:

        function isDebug() {

            return @(HttpContext.Current.IsDebuggingEnabled);

        }

 Then use in your code:

        if (isDebug) { alert("customers do not want to see this"); }

 

Beware isDebug() is global with this implementation.

Happy coding!

How-to Fix: A Downloaded Project Compile Error: Could not load file or assembly packages\ … or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Could not load file or assembly packages\ … or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) Cause: The \packages folder and/or files is blocked. Fix: Backup and Delete the solution’s \packages\ folder, allowing NuGet to restore packages.
How-to: Use Visual Studio SQL Server Data Tools (SSDT)
This article describes the process of developing the entire Data Tier in Visual Studio SQL Server Data tools (SSDT.) Many Software Development Life Cycle (SDLC) processes use hand-coded SQL publish scripts when making changes to the data tier. This process is error prone, and is not able to be versioned as easily as C# code projects. SSDT is a technology that brings the data tier in-line with C# projects, and both can be developed, versioned and released in the same manner.
How-to: Add ClickOnce Setup and Deployment to your App
ClickOnce will auto-manage everything about desktop-app deployment, updating and execution. You can start an app via Url, everything else is automatic. Running an exe Url like this will: http://www.domain.com/ProductSetupFolder/MajorVersion/Setup.exe •Verify OS, security, permissions requirements •Auto-install .Net Framework and all 3rd party dependencies •Auto-install the app •Auto-update the app when newer versions exist on the server •Auto-run the app