How to setup Angular2 and ASP.NET Core from the command line


Setting up Asp.Net Core and Angular2 is actually very easy! There are several ways to setup a project. Before we can start using the command line, we need to install the following: ASP.NET Core installers npm – $ npm install npm@latest -g Yeoman – $ npm install -g yo Step 1: From the command line install the JavaScript Services generator: npm install -g yo generator-aspnetcore-spa Step 2: Run the generator using the yo aspnetcore-spa command and choose Angular 2 from the list of templates.

Understanding what happens during a complex LAMBDA query


LAMBDA expressions were introduced in C# 3.0 (.NET 3.5) along with LINQ. The LAMBDA expression is a shorter way of representing anonymous methods using special syntax. For example, the following anonymous method checks if the customers balance is over $1000: Anonymous method in C#: The above anonymous method can be rewritten using the following: Lambda Expression in C#: c => c.Balance > 1000 Below is a more complex LAMBDA expression:

What is the difference between Optimistic Concurrency versus Pessimistic Concurrency


Optimistic Locking is a way of versioning your record by add either a date, timestamp or hash. If there are multiple users updating that record, the software will know if the record has changed based on the hash. The reason for this is that you have to make sure the version is atomic. This means that the record hasn’t been updated by another user while you were editing the value.

Whats the difference between Expression> and Func<>?


The key differences between the two are following: Expression> is an expression tree which represents the original source code (it is stored in a tree-like data structure that is very close to the original C# code). In this form, you can analyze the source code and tools like LINQ to SQL can translate the expression tree (source code) to other languages (e.g. SQL in case of LINQ to SQL, but you could also target e.

Whats the difference between IEnumerable and IQueryable?


The main difference between the 2 is that of efficiency: IEnumerable will return all the records at once. IQueryable will return only records that you want based on a filter that executes on the server. How does each work? Let’s assume that you have a customer table with all your customer’s information with about 10000 clients. If you use IEnumerable to get the first 10 customers you end up loading all 10000 and then selecting the first 10.

Why you shouldn’t use a static variable in your MVC Controller


I recently came across an interesting situation where I used a static variable in a controller and it caused some issues. The problem with statics variables is that they are not thread safe meaning that they could potentially be executed by multiple threads. This is an issue because different users could access other users information if it is stored in a static variable.

How to build Reactive Forms in Angular2


When building forms using the Reactive approach the component class is in charge. In order to implement this we have to: Create a property for the root FormGroup. Create the FormGroup instance. Pass in each FormControl instance. Here is an example of how to implement this using typescript: ngOnInit(): void(){ this.contactForm = new FormGroup({ firstName: new FormControl(), lastName: new FormControl(), email: new FormControl(), sendCatalog: new FormControl(true), }); } The above code is not very efficient.

How components communicate in VueJS


Components in VueJS communicate in a Unidirectional manner Using Custom Event and Props When trying to pass data from Child 1 to the Parent, you have to use the Props method and the Emit method. You got props to pass data from a PARENT => CHILD. You got events ($emit ) to pass data from CHILD => PARENT. Using v-on with Custom Events Every Vue instance implements an events interface, which means it can: