SQL and Indexed Views

So we have a fairly complex table structure to deal with when it comes to determining how products are moved about a district.  A product can have numerous statuses from in use, available,  in transit and etc.. etc..etc…  Often our business annalist want to know what, when and who — plus a nice report or chart so others can view this information and while your at it pivot the custom fields…  In our website we have one page that gathers up data across 40 various tables, pivots and calculates information in a user friendly and searchable manner.  A medium sized customer will realize the table structure in memory on our server and load up the system with a possible 78 megs of simple data.   As you can imagine the loading time on the page was dismal, plus if you started to page and etc … well, you had to wait .. and wait while the pager index was recalculated and etc… This was just not making the developers and customers very happy at all… After much refactoring, streamlining, grooming and optimization we go the first load of the page down to a reasonable amount of time, but we were still not happy with the results.  Our next plan of attack was to look at the LINQ TO SQL statements that the page depended on.  In the end, we dumped the linq to sql moving instead to a series of indexed views which were aggregated to a simple user defined function in sql server 2008 r2.  This not only improved the pages performance, it greatly reduced the memory load on the server to boot.

This article; by simple talk, is something I highly recommend folks read if you are trying to squeeze a second or two from your website page load times…

 https://www.simple-talk.com/sql/learn-sql-server/sql-server-indexed-views-the-basics/

IOC with WCF…

So if you have used a repository pattern with WCF and tried to run the built-in WCF Client app you most likely have seen this error:

The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to the host.

You get this when your Servce class looks something like this:

public class SiteService : Service, ISiteService
{
private readonly IRepositoryAsync _asynRepository;

public SiteService(IRepositoryAsync repository)
: base(repository)
{
_asynRepository = repository;
}

That is expected because the IInstanceProvider only works with empty default constructors (with a few exceptions) and as you can see we are expecting a dependency.  In this case a repository, but it could be any dependency such as another service.

Anyway, I know Ninject provides a solution you can get from the Nuget library via the Ninject.Extensions.Wcf, but…. I want to try out using Unity and from what I understand there are community supported solutions too.

…. More to come…

Implemented a Repository and Unit of Work code challenge

I just finished up implementing a Repository and Unit of Work code challenge using a Generic’s based Repository pattern.

My next steps will be to integrate Unity into the WCF Servce, should be in interesting next step.  I did read about a few people using MEF, but I need to do a bit more study on it.

Here is the GIT HUB if you like to dig about:  https://github.com/warrenla/QV_GenericRepository

JS Build Automation Tools

major js players

$npm install -g gulp

$npm install -g bower

Verify install

$ gulp -v

$ bower -v

You can also list all global packages installed with NPM

$ npm list -g –depth=0

Install packages for a specific project locally

CRITICAL MAKE SURE YOU ARE IN YOUR PROJECT FOLDER BEFORE RUNNING LOCAL COMMANDS

npm install –save-dev packageName

replace packagename

npm install gulp –save-dev   (install gulp locally)

–save-dev  = saves it to devDependencies in package,json

So my commands to update the package.json file devDependencies

$npm install –save-dev gulp

Some more tools

Use this tool to detect errors and potential problems.

Using gulp to install so you can do project wide checking via gulp task

$npm install –save-dev gulp-jscs gulp-jshint

You will need to update the gulp file also for the require statements.

var jshint = require(‘gulp-jshint’);

var jscs = require(‘gulp-jscs’);

Credit to John Papa for his plural sight course JS Build Automation.