LICT .NET Training | Kamal Protap Sir | Part 5

16/11/2017 vids

ExtensionMethod
Object Initializer
CollectionInitializer
QueryExpression
– It contains three clauses
from, where, orderby
Linq
IEnumerable

Diffrenet Datasource:
Array, Database, XML,LIST/Collection also datasource, File Concept also data source
Data we can able to store in known as data source
Data source: Where the data is available

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

namespace linqSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num=new int[5]{45, 78,45,34,2};
            IEnumerable<int> res=from N in num
                                 where N>40
                                 orderby N
                                 select N;

            foreach (var item in res)
            {
                Console.WriteLine(res);
            }

            Console.ReadKey();
        }
    }
}

Linq-Language Integrated Query
What is strongly typed ?

Strongly typed means:
Which show error immediately at a time of declaration that  is called strongly typed. It is also called compile time error.

Weakly typed means:
Which show error in runtime is called weakly typed like delegate.It is also known as loosely type.

Intellisense and Strongly typed is supproted in LINQ concept.

LINQ enabled data sources is very very important for interview:
LINQ to Objects : It means with array, arralist, etc.
LINQ to Datasets: It’s connected with ADO.NET
LINQ to SQL: It’s connected to SQL
LINQ to Entities: It’s connected to other data base like oracle or mysql
LINQ to XML: It’s connected to XML files

IQueryable
Where IQueryable is inherited from IEnumerable
IEnumerable

There are two expression in LINQ QueryExpression and methodExpression

Differed Execution:

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

namespace linqSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num=new int[5]{45,78,45,34,2};
            IEnumerable<int> res=from N in num
                                 where N>40
                                 orderby N descending 
                                 select N;

            foreach (var item in res)
            {
                Console.WriteLine(item);
            }

            Console.ReadKey();
        }
    }
}

 

Forced Execution:

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

namespace linqSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num=new int[5]{45,78,45,34,2};
            IEnumerable<int> res=(from N in num
                                 where N>40
                                 orderby N descending 
                                 select N).ToArray();

            foreach (var item in res)
            {
                Console.WriteLine(item);
            }

            Console.ReadKey();
        }
    }
}

 

Immediate:

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *