EPi.Extensions is library with useful extension methods and helpers for EPiServer.
github.com/Geta/EPi.Extensions/blob/master/README.md
Author: Andreas Plahn
How to fetch the row count for all tables in a SQL SERVER database
The following SQL will get you the row count of all tables in a database:
CREATE TABLE #counts ( table_name varchar(255), row_count int ) EXEC sp_MSForEachTable @command1='INSERT #counts (table_name, row_count) SELECT ''?'', COUNT(*) FROM ?' SELECT table_name, row_count FROM #counts ORDER BY table_name, row_count DESC DROP TABLE #countsThe output will be a list of tables and their row counts.
If you just want the total row count across the whole database, appending:
SELECT SUM(row_count) AS total_row_count FROM #countswill get you a single value for the total number of rows in the whole database.
Source: How to fetch the row count for all tables in a SQL SERVER database – Stack Overflow
How to migrate a SQL Server database to a lower version
…there are a few options that can help us to downgrade the database from a higher version of SQL Server to a lower version SQL Server. These options include:
- Generate Scripts wizard of SQL Server Management Studio
- SQL Server Integration Services
- Custom scripting and BCP
In this tip we will use the Generate Scripts wizard of SQL Server Management Studio.
Source: How to migrate a SQL Server database to a lower version
Keeping your ASP.NET WebAPI Controllers lean with the use of Filters | Digital Affinity
“In a constant battle to reduce the amount of duplication and technical debt in the code I write, I am always revisiting code and looking at how I can reduce the amount of maintenance work I need to perform.”
See source: Keeping your ASP.NET WebAPI Controllers lean with the use of Filters | Digital Affinity
Batch convert a folder of images from png to jpg
I had a bunch of png images in several subfolders which I wanted to convert into jpg.
I used the command line tool ImageMagick for Windows, which is free and can be downloaded here:
Download @ ImageMagick
This command will convert all images in the folder and its subfolders from png to jpg with quality 65. The converted files will get the same filename but with jpg extension:
for /R %f in (*.png) do ( convert -quality 65 "%f" "%~npf.jpg" )
convert is the ImageMagick command running, for /R is used for looping recursively.
Use this command when done to remove all the source png files:
del *.png /s
This will delete all png files in this folder and all subfolders.
How to increase upload size of a document in an asp.net application. | The ASP.NET Forums
Re: how to increase upload size of a documnet upto 20 MB….in an asp.net application. Aug 04, 2013 08:25 AM|LINK You likely will need to update your maxRequestLength within your web.config to handle files and uploads that are large (as the default limit is often 4MB). This can be handled within the section of your web.config or the section if you want to handle it at the IIS level (both are probably a good idea). It’s important to know that maxAllowedContentLength is measured in bytes and maximumRequestLength is measured in kilobytes when settings these values so you’ll need to adjust them accordingly if you plan on handling much larger files : If you wanted to use 20MB as a limit, you would need to change the values to the following respectively : If you don’t see these sections within your existing web.config file, you’ll simply need to copy them in. Updating the maxRequestLength property is likely going to be the easiest method of handling this, however there are alternatives such as libraries like NeatUpload, which are designed to handle large files and can handle uploading files as streams to your preferred method of storage.
Find in ANY table in your database
I needed to search in all tables for a certain GUID, I used this SP in MS SQL Server 2016: Find a GUID (or anything) in ANY table in your database! | CSharpner.com
How to copy tables from one database to another in SQL Server
See heading: Using SQL Server Export / Import wizard
Solution for responsive images covering entire container and keeping aspect ratio
This solution is probably already out there somewhere on the interwebs, but I write it down for now.
I’ve been working with a Bootstrap 4 based website a lot lately.
Today I got the requirement to make an background image adjust to the height of its sibling column but at the same cover the entire background of its container.
I want the entire container box to be covered by the background image and still keeping its aspect ratio in various screen sizes, it’s ok with clipping and stretching (if image is to small). Here is a solution:
html:
<div class="row"> <div class="col-6"> <div class="teaser-container" id="teaser1"> ...column 1 html content... </div> </div> <div class="col-6"> <div class="teaser-container" id="teaser2"> ...column 2 other various height html content... </div> </div> </div>
css:
#teaser1 { height: 100%; background-image: url('/globalassets/top-image.jpg'); background-repeat: no-repeat; background-position: center; background-size: cover; }
Throttling your API in ASP.NET
Can someone DOS attack your API and bring down your webservice? Could I hit your API at 100 requests a second and bring down your server?
Source: Throttling your API in ASP.NET