Sunday 25 October 2015

Update Navigation property in Many-to-Many Entity using DBContext













I have seen that many people getting trouble with updating many-many relationship in EF. In this post i will show how to update Many-to-Many Entity using DbContext. In short we will se how to navigation property in many to many relationship.















Post and Category has Many-to-Many ralationship.

This is PostTable Entity class.
[Table("PostTable")]

Sunday 18 October 2015

Runtime polymorphism













We will declare vehicle inteface here, interface will tell what should implement not how to implement.
    //Vehicle.cs
    public interface Vehicle
    {
        void engine();
        void breaks();
    }

Saturday 17 October 2015

C# program to check the performance of Generics.













This program shows the difference between Generics and Non-Generic . It checks the performance of Generics. Generics are faster than Non-Generics it takes less time to add and retrieve any type of values. Below program gives the demonstration on performance and shows how powerful is Generics.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;

namespace GenericsPerformance
{
    class Program
    {
        static void Main(string[] args)
        {
            NonGenericMethod();
            GenericMethods();
        }

C# program for swapping using generics













We are using this program to swap any type of data using Generics.

using System;
using System.Collections.Generic;

namespace SwapingUsingGenerics
{

Friday 16 October 2015