31 July 2013

Covariance .Net Framework 4.0

Covariance .Net Framework 4.0

Covariance preserve assignment compatibility between Parent and Child relationship during dynamic polymorphism

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Covariance
{

    class Program
    {
        static void Main(string[] args)
        {

            List objAthelete = new List();
            objAthelete.Add(new Athelete
            {
                SportName = "100 meter",
                SportsType = "Running"
            });

            IEnumerable Persons = objAthelete;

            Athelete objAth = new Athelete();
            //objAth.PrintAll(Persons);
        }
    }


    public class Person
    {
        public string Name { get; set; }
        public string City { get; set; }
    }

    public class Athelete : Person
    {

        public string SportName { get;set; }
        public string SportsType { get;set; }

        public void PrintAll(IEnumerable objects)
        {
            foreach (Athelete o in objects)
            {
                Console.WriteLine("Sports Name:" + o.SportName + "Sports Type:" + o.SportsType);
            }
        }
    }
}

The following error is thrown when the application is run in .Net framework 3.5, but it support in 4.0 framework.





27 July 2013

Add multiple model in View MVC 3 and MVC 4

Add multiple model in View MVC 3 and MVC 4

Using Tuple it is possible, Add below code in the view.

@model Tuple< Model1,Model2 >

Example : http://pastebin.com/VBPhBBUw


Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...