Skip to main content

Posts

Showing posts from September, 2020

Backup and Restore Database Commands

  BACKUP   DATABASE   [DB_Name]         TO   DISK   =   N'\\server\directory\backupfile.bak'         WITH   NOFORMAT ,   INIT ,   NAME = N'DBNAME' ,   SKIP ,      NOREWIND ,   NOUNLOAD ,   STATS = 10 ;   RESTORE   FILELISTONLY                FROM   DISK =   N '\\server\directory\backupfile.bak'   DROP   DATABASE   [DB_Name]   ;   RESTORE   DATABASE   [DB_Name]             FROM   DISK = ' '\\server\directory\backupfile.bak'         WITH         MOVE   'DB_logicalName'   TO                'D:\Databases\data file name. mdf ' ,         MOVE   ' DB_Log Name _log'   TO                         'E:\Logs\log file name_log.ldf'    

Using GetEnumerator

  The tips are:  Seems to work better if you know the type you want back from GetEnumerator, notice the IEnumerator<Employee> Notice the use of Current

Good article on getting the right characters of a string in C#

Left, Right, SubString C#   https://kodify.net/csharp/strings/left-right-mid/#left-right-and-mid-string-segments-in-c Feature Description C# equivalent Left Get specific number of characters ( count ) from left part string.Substring(0, count) Right Get specific number of characters ( count ) from right side string.Substring(string.Length - count, count) Mid Get a specific number of characters ( count ) starting at a certain point ( index ) string.Substring(index, count) Mid Get all characters starting at a certain point ( index ) string.Substring(index)

Accessing localhost Web API from an android emulator on Windows

 There is a preconfigured IP address, for the emulator to access.  The IP Address is 10.0.2.2 ie: use something like https://10.0.2.2:5001/api/customers You'll end up with something like... private string baseurl = Device.RuntimePlatform == Device.Android ?     " https://10.0.2.2:5001/api" :     " https://localhost:5001/api" ; 

How to trust IIS Certificates for Development

 Type the following on a command line  > dotnet dev-certs https --trust If you're accessing the dev site from another computer or device, via an application, you can disable ssl certificate checking in the client app with... HttpClientHandler handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = ( message, cert, chain, errors ) =>  { if(cert.Issuer.Equals("CN=localhost"))                    { return true;                     } return errors == System.Net.Security.SslPolicyErrors.None; }; Notes about Android and Xamarin Requires TLS 1.2 The default AndroidClientHandler supports TLS 1.2, but only for Android versions greater than 4.1 If an Android version is needed that is lower than 4.1, then we'll need to use the HttpClientHandler which supports TLS 1.0.  It is slower and increases the package size. Notes about iOS and Xamarin Requires TLS 1.2 The HttpClient uses NSUrlSession, this is the default and supports TL