Tuesday, 28 March 2017

New post

1:  import { NgModule }   from '@angular/core';  
2:  import { BrowserModule } from '@angular/platform-browser';  
3:  import { AppComponent } from './app.component';  
4:  @NgModule({  
5:   imports:   [ BrowserModule ],  
6:   declarations: [ AppComponent ],  
7:   bootstrap:  [ AppComponent ]  
8:  })  
9:  export class AppModule { }  

Monday, 27 March 2017

Eager loading, Lazy loading and work through using DTOs

Eager Loading: use the Include method like
db.books.Include(b=>b.Related_entity);

Lazy Loading: EF automatically loads the related entity when navigation property is referenced. To enable lazy loading, make the navigation property virtual.
public virtual Author Author{get;set;}

Problem of Circular Reference during Serializing models.
When both entities have navigation property with each other, it created a problem when we serialize the models. It creates a circular object graph.

Solution:
We need to use DTO and load all data in them before returning it. 

Code first Data Migration EF

In Code First we write the code first (Models) and let migration tools create tables.

From Tools --> Library Package Manager --> Package Manager Console.
Enter command:  Enable-Migrations
This command adds a folder named Migrations and file Configuration.cs in the folder.
The file has Seed method to pre-load the tables with data.

Type command: Add-Migration Initial
update-database
The first command generates code that creates the database and second command executes that code.


Bevereages

Types of Beverages Fermented - yeast reacts with sugar to convert into ethyl alcohol & CO2. 4-14% Wine (red, white & rose), Cider ...