SlideShare a Scribd company logo
1 of 48
Sanjay Vyas
The LINQ Project
   C#              VB                 Others…


 .NET Language Integrated Query

   Standard        LINQ To SQL
                                      LINQ To XML
   Query           LINQ To Dataset
   Operators       LINQ To Entities


                                          <book>
                                            <title/>
                                            <author/>
                                            <year/>
                                            <price/>
                                          </book>




        Objects         Database           XML
Language Innovations
                                                 Query
                                                 expressions
                 var contacts =
                   from c in customers
                   where c.State == quot;WAquot;
                   select new { c.Name, c.Phone };
Local variable
type inference
                                          Lambda
                                          expressions
                 var contacts =
                   customers
                   .Where(c => c.State == quot;WAquot;)
                   .Select(c => new { c.Name, c.Phone });
Extension
methods                                                 Object
            Anonymous                                   initializers
            types


                                                                       3
Lambda Expressions
  public delegate bool Predicate<T>(T obj);

  public class List<T>
  {                                                 Statement
                                                    context
Explicitly List<T> FindAll(Predicate<T> test) , … -
     public
typed…
  }                                                         Implicitly
        List<Customer> customers = GetCustomerList();       typed
   List<Customer> x = customers.FindAll(                          Expression
      delegate(Customer c) { return c.State == quot;WAquot;; }            context
   );


   List<Customer> x = customers.FindAll(c => c.State == quot;WAquot;);




                                                                   4
Lambda Expressions
 public delegate T Func<T>();
 public delegate T Func<A0, T>(A0 arg0);
 public delegate T Func<A0, A1, T>(A0 arg0, A1 arg1);
 …

 Func<Customer, bool> test = c => c.State == quot;WAquot;;

 double factor = 2.0;
 Func<double, double> f = x => x * factor;

 Func<int, int, int> f = (x, y) => x * y;

 Func<int, int, int> comparer =
   (int x, int y) => {
      if (x > y) return 1;
      if (x < y) return -1;
      return 0;
   };
                                                        5
Queries Through APIs
                                           Query operators are
                                           just methods
  public class List<T>
  {
    public List<T> Where(Func<T, bool> predicate) , … -
    public List<S> Select<S>(Func<T, S> selector) , … -
    …
  }                                                              Methods compose to
                                                                 form queries
         List<Customer> customers = GetCustomerList();

     List<string> contacts =
        customers.Where(c => c.State == quot;WAquot;).Select(c => c.Name);
But what about other
types?              Declare operators in
                    all collections?                      Type inference
                                                          figures out <S>
          What about arrays?


                                                                     6
Queries Through APIs
                                                Query operators are
                                                static methods
 public static class Sequence
 {
   public static IEnumerable<T> Where<T>(IEnumerable<T> source,
     Func<T, bool> predicate) , … -

   public static IEnumerable<S> Select<T, S>(IEnumerable<T> source,
     Func<T, S> selector) , … -
   …
 }                                                               Huh?
           Customer[] customers = GetCustomerArray();

       IEnumerable<string> contacts = Sequence.Select(
           Sequence.Where(customers, c => c.State == quot;WAquot;),
           c => c.Name);


                                      Want methods on
                                      IEnumerable<T>


                                                                7
Extension Methods
                                                       Extension
 namespace System.Query                                methods
 {
   public static class Sequence
   {
     public static IEnumerable<T> Where<T>(this IEnumerable<T> source,
       Func<T, bool> predicate) , … -

     public static IEnumerable<S> Select<T, S>(this IEnumerable<T> source,
                                                             obj.Foo(x, y)
       Func<T, S> selector) , … -
     …                                                       
   }                                Brings extensions        XXX.Foo(obj, x, y)
 }                                  into scope
       using System.Query;

  IEnumerable<string> contacts =
    customers.Where(c => c.State == quot;WAquot;).Select(c => c.Name);


                   IntelliSense!

                                                                   8
Object Initializers
 public class Point
 {
   private int x, y;

     public int X { get { return x; } set { x = value; } }   Field or property
     public int Y { get { return y; } set { y = value; } }   assignments
 }


                 Point a = new Point { X = 0, Y = 1 };



                 Point a = new Point();
                 a.X = 0;
                 a.Y = 1;




                                                                        9
Object Initializers
                                               Embedded
 public class Rectangle                        objects
 {
   private Point p1 = new Point();
   private Point p2 = new Point();                Read-only
                                                  properties
     public Point P1 { get { return p1; } }
     public Point P2 { get { return p2; } }
 }
              Rectangle r = new Rectangle {
                 P1 = { X = 0, Y = 1 },
                 P2 = { X = 2, Y = 3 }         No “new Point”
              };


              Rectangle r = new Rectangle();
              r.P1.X = 0;
              r.P1.Y = 1;
              r.P2.X = 2;
              r.P2.Y = 3;

                                                                10
Collection Initializers
                                        Must implement
                                        ICollection<T>


 List<int> powers = new List<int> { 1, 10, 100, 1000, 10000 };


                        List<int> powers = new List<int>();
                        powers.Add(1);
                        powers.Add(10);
                        powers.Add(100);
                        powers.Add(1000);
                        powers.Add(10000);




                                                                 11
Collection Initializers
  public class Contact
  {
    private string name;
    private List<string> phoneNumbers = new List<string>();

      public string Name { get { return name; } set { name = value; } }
      public List<string> PhoneNumbers { get { return phoneNumbers; } }
  }
           List<Contact> contacts = new List<Contact> {
              new Contact {
                 Name = quot;Chris Smithquot;,
                 PhoneNumbers = { quot;206-555-0101quot;, quot;425-882-8080quot; }
              },
              new Contact {
                 Name = quot;Bob Harrisquot;,
                 PhoneNumbers = { quot;650-555-0199quot; }
              }
           };

                                                                     12
Local Variable Type Inference
    int i = 5;
    string s = quot;Helloquot;;
    double d = 1.0;
    int[] numbers = new int[] {1, 2, 3};
    Dictionary<int,Order> orders = new Dictionary<int,Order>();


    var i = 5;
    var s = quot;Helloquot;;
    var d = 1.0;
    var numbers = new int[] {1, 2, 3};
    var orders = new Dictionary<int,Order>();


       “var” means same
       type as initializer



                                                             13
Anonymous Types
 public class Customer
 {
   public string Name;
   public Address Address;            public class Contact
   public string Phone;               {         class ???
   public List<Order> Orders;           public string Name;
                                                {
   …                                    public string Phone; Name;
                                                   public string
 }                                    }            public string Phone;
Customer c = GetCustomer(…);                  }
Contact x = new Contact { Name = c.Name, Phone = c.Phone };

Customer c = GetCustomer(…);
var x = new { Name = c.Name, Phone = c.Phone };

                                                  Projection style
Customer c = GetCustomer(…);                      initializer
var x = new { c.Name, c.Phone };


                                                                     14
Anonymous Types
      var contacts =
        from c in customers
        where c.State == quot;WAquot;
        select new { c.Name, c.Phone };          class ???
                                                 {
      IEnumerable<???>                              public string Name;
                                                    public string Phone;
                                                 }
      var contacts =
        customers.
        .Where(c => c.State == quot;WA“)
        .Select(c => new { c.Name, c.Phone });
???

      foreach (var c in contacts) {
        Console.WriteLine(c.Name);
        Console.WriteLine(c.Phone);
      }


                                                                 15
Query Expressions
 Language integrated query syntax


                                       Starts with from
                                                          Zero or more from
                                                          or where
 from id in source
 { from id in source | where condition }
 [ orderby ordering, ordering, … ]                            Optional
 select expr | group expr by key                              orderby
 [ into id query ]
                                                          Ends with select or
                                   Optional into          group by
                                   continuation



                                                                  16
Query Expressions
 Queries translate to method invocations
    Where, Select, SelectMany, OrderBy, GroupBy


      from c in customers
      where c.State == quot;WAquot;
      select new { c.Name, c.Phone };




      customers
      .Where(c => c.State == quot;WAquot;)
      .Select(c => new { c.Name, c.Phone });



                                               17
Expression Trees
 public class Northwind: DataContext
 {
   public Table<Customer> Customers;
   public Table<Order> Orders;                            How does this get
   …                                                      remoted?
 }
     Northwind db = new Northwind(…);
     var query = from c in db.Customers where c.State == quot;WAquot; select c;

    Northwind db = new Northwind(…);                              Method asks for
    var query = db.Customers.Where(c => c.State == quot;WAquot;);         expression tree

  public class Table<T>: IEnumerable<T>
  {
    public Table<T> Where(Expression<Func<T, bool>> predicate);
    …
  }
                                        System.Expressions.
                                        Expression<T>
                                                                  18
Expression Trees
 Code as Data
                  Func<Customer, bool> test = c => c.State == quot;WAquot;;

    Expression<Func<Customer, bool>> test = c => c.State == quot;WAquot;;


    ParameterExpression c =
      Expression.Parameter(typeof(Customer), quot;cquot;);
    Expression expr =
      Expression.EQ(
         Expression.Property(c, typeof(Customer).GetProperty(quot;Statequot;)),
         Expression.Constant(quot;WAquot;)
      );
    Expression<Func<Customer, bool>> test =
      Expression.Lambda<Func<Customer, bool>>(expr, c);


                                                               19
Language Innovations
                                    c => c.Name
 Lambda expressions
 Extension methods               static void Dump(this object o);

 Local variable type inference                     var x = 5;

 Object initializers
                            new Point { x = 1, y = 2 }
 Anonymous types
                                 new { c.Name, c.Phone }
 Query expressions
                           from … where … select
 Expression trees
                          Expression<T>

                                                  20
Why Do We Need LINQ
  Object-Relation mismatch

  • O-R Mapping tools – EJB, Hibernate

  Object-Hierarchical mismatch

  • OODBMS, Code generators

  Object-XML mismatch

  • SAX, DOM Model

  Complex Call Level Interfaces

  • ODBJ, JDBC, ADO.NET

  Code readability & maintenance issue
Flavours of LINQ
 LINQ To Objects    LINQ To Amazon
 LINQ To XML        LINQ To Flickr
 LINQ To SQL        LINQ To Nhibertnate
 LINQ To DataSets   LINQ To LDAP
 LINQ To Entities   LINQ To Google
 PLINQ              LINQ To SharePoint
Evolution



.NET             .NET            .NET          .NET
       Core IL        Generics          LINQ          PLINQ
 1.0              2.0             3.0           4.0
Foundation

      LINQ Query Expression
IEnumable/IQueryable   Extension Methods         Lambda          Anonymous Types       Collection Initializers




      Generics          Static Methods     Anonymous Delegates   Object Initializers      ICollection<T>
LINQ to SQL
Accessing data today

                                                     Queries in
   SqlConnection c = new SqlConnection(…);            quotes
   c.Open();
   SqlCommand cmd = new SqlCommand(
     @quot;SELECT c.Name, c.Phone                      Loosely bound
        FROM Customers c                             arguments
        WHERE c.City = @p0quot;);
   cmd.Parameters.AddWithValue(quot;@p0quot;, quot;London“);
   DataReader dr = c.Execute(cmd);                  Loosely typed
   while (dr.Read()) {                                result sets
      string name = dr.GetString(0);
      string phone = dr.GetString(1);
      DateTime date = dr.GetDateTime(2);           No compile time
   }                                                   checks
   dr.Close();
LINQ to SQL
Accessing data with LINQ

                                          Classes describe
   public class Customer , … -                  data

   public class Northwind : DataContext
                                           Tables are like
   {                                         collections
     public Table<Customer> Customers;
     …
   }                                       Strongly typed
                                            connections
   Northwind db = new Northwind(…);
   var contacts =                         Integrated query
     from c in db.Customers                    syntax
     where c.City == quot;Londonquot;
     select new { c.Name, c.Phone };
                                           Strongly typed
                                               results
LINQ to SQL
 Language integrated data access
    Maps tables and rows to classes and objects
    Builds on ADO.NET and .NET Transactions
 Mapping
    Encoded in attributes or external XML file
    Relationships map to properties
 Persistence
    Automatic change tracking
    Updates through SQL or stored procedures
DataContext
• A DataContext is used to scope changes made to classes
  defined by LINQ to SQL
•    A DataContext is responsible for keeping references to all
    LINQ to SQL classes, their properties, and foreign key
    relationships.
•    A DataContext is not meant to be kept around; we want to
    create a new context for every “unit of work” to avoid
    concurrency issues. There are multiple ways to approach this.
•   A DataContext is the API to the database, but at this stage it
    does not contain any business logic that is not implied by the
    database schema.
Defining DataContext
 Inherit from DataContext
 Override Constructor(s)


  *Database(Name = “MyDBquot;)]
  public class MyDataContext : DataContext
  {
      public MyDataContext(string connString)
                     : base(connString)
      {
      }
  }
Creating DataContext
Similar to SqlConnection()

   public static void Main()
   {
      string connString = “server=MyServer; database=MyDb”;
     MyDataContext context = new MyDataContext(connString);
     :
     :
     :
   }
LINQ Queries
 SQL “like” Syntax
 Not a hack/kludge
 Built upon            var result = from cust in context.Customers
                                      where cust.Location = “Pune”
   Generics                           select cust;

   Extension methods   foreach (Customer c in result)
                       {
   Lamdas                 Console.WriteLine(c.CustomerName);
                       }
LINQ Queries
 LINQ To SQL fetches data from database
 Populates the Table Object/EntitySet
 Basic LINQ semantics allows iteration
join Query
 SQL “Like” join
 Inner join implemented as natural syntax
 Outer joins thru “DataShapes”

  var result = from c in Customers
                 join o in Order on c.CustomerID equals o.CustomerID
                 select new { c.CustomerName, o.OrderID }

  foreach (var v in result)
  {
     Console.WriteLine(v);
  }
Attribute Mapping
 Declarative mapping
 No code required
 Map Relational to Objects

  *Table(Name=“prod”)+
  public class Product
  {
     *Column(Name=“ProdId”, IsPrimaryKey=true)]
      public string ProductID;

      [Column]
      public string ProductName;
  }
XML Mapping
 Externalized mapping
 Can be modified without rebuild
 Can be generated dynamically
Sample xml mapping file
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<Database Name=quot;northwindquot; xmlns=quot;http://schemas.microsoft.com/linqtosql/mapping/2007quot;>
 <Table Name=quot;dbo.Customersquot; Member=quot;Customersquot;>
  <Type Name=quot;Customerquot;>
   <Column Name=quot;CustomerIDquot;
       Member=quot;CustomerIDquot;
       Storage=quot;_CustomerIDquot;
       DbType=quot;NChar(5) NOT NULLquot;
       CanBeNull=quot;falsequot;
       IsPrimaryKey=quot;truequot; />
   <Column Name=quot;CompanyNamequot;
       Member=quot;CompanyNamequot;
       Storage=quot;_CompanyNamequot;
       DbType=quot;NVarChar(40) NOT NULLquot;
       CanBeNull=quot;falsequot; />
  </Type>
 </Table>
</Database>
Code Generation Tools
 Attribute and XML can be manually generated
 CodeGen Tools
    VS Designer Tool
      Link to SQL class item
      Server Explorer Drag and Drop
    SQLMetal.exe
      Can generate DBML (Database Markup Language)
      XML Mapping File
      Attribute mapped code file (.cs|.vb)
    VLinq
      Visual design LINQ Queriesp://code.msdn.microsoft.com/vlinq
LINQ Associations
 Mirror database relation in object collection
 Master-Detail mapping
 Data available thru Object Collections
  *Table(Name=“Customers”+
  Class Customer
  {
     [Column] public string CustomerID;
     [Column]public string CompanyName;

      [Association(ThisKey=“CustomerID”, OtherKey=“CustomerID”+
      public EntitySet<Order> orders;
  }

  *Table(Name=“Orders”)+
  public class Order
  {
     [Column] public string CustomerID;
     [Column] public stringOrderID;
  }
Association Thru XMLMapping
      Similar to attribute

<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<Database Name=quot;northwindquot; xmlns=quot;http://schemas.microsoft.com/linqtosql/mapping/2007quot;>
 <Table Name=quot;dbo.Customersquot; Member=quot;Customersquot;>
  <Type Name=quot;Customersquot;>
   <Column Name=quot;CustomerIDquot; Member=quot;CustomerIDquot; Storage=quot;_CustomerIDquot; DbType=quot;NChar(5) NOT NULLquot; CanBeNull=quot;falsequot; IsPrimaryKey=quot;truequot; />
   <Column Name=quot;CompanyNamequot; Member=quot;CompanyNamequot; Storage=quot;_CompanyNamequot; DbType=quot;NVarChar(40) NOT NULLquot; CanBeNull=quot;falsequot; />
   <Association Name=quot;FK_Orders_Customersquot; Member=quot;Ordersquot; Storage=quot;_Ordersquot; ThisKey=quot;CustomerIDquot; OtherKey=quot;CustomerIDquot;/>
  </Type>
 </Table>

 <Table Name=quot;dbo.Ordersquot; Member=quot;Ordersquot;>
  <Type Name=quot;Ordersquot;>
   <Column Name=quot;OrderIDquot; Member=quot;OrderIDquot; Storage=quot;_OrderIDquot; DbType=quot;Int NOT NULL IDENTITYquot; IsPrimaryKey=quot;truequot; IsDbGenerated=quot;truequot;
AutoSync=quot;OnInsertquot; />
   <Column Name=quot;CustomerIDquot; Member=quot;CustomerIDquot; Storage=quot;_CustomerIDquot; DbType=quot;NChar(5)quot; />
   <Column Name=quot;OrderDatequot; Member=quot;OrderDatequot; Storage=quot;_OrderDatequot; DbType=quot;DateTimequot; />
  </Type>
 </Table>
</Database>
Call StoreProcedures
 SPs can be mapped thru attributes or XML
 Call semantics similar to tables
 Supports parameter passing (in/out)
 Existing Entity behaviour can be changed to use
 SPs instead of SQL
LINQ to Entities
         using(AdventureWorksDB aw = new
         AdventureWorksDB(Settings.Default.AdventureWorks)) {
           Query<SalesPerson> newSalesPeople = aw.GetQuery<SalesPerson>(
             quot;SELECT VALUE sp quot; +
             quot;FROM AdventureWorks.AdventureWorksDB.SalesPeople AS sp quot; +
             quot;WHERE sp.HireDate > @datequot;,
             new QueryParameter(quot;@datequot;, hireDate));

             foreach(SalesPerson p in newSalesPeople) {
               Console.WriteLine(quot;{0}t{1}quot;, p.FirstName, p.LastName);
             }
         }




         using(AdventureWorksDB aw = new
         AdventureWorksDB(Settings.Default.AdventureWorks)) {
           var newSalesPeople = from p in aw.SalesPeople
                      where p.HireDate > hireDate
                      select p;

             foreach(SalesPerson p in newSalesPeople) {
               Console.WriteLine(quot;{0}t{1}quot;, p.FirstName, p.LastName);
             }
         }
Parallel LINQ
Declarative Data Parallelism
Parallel LINQ-to-Objects (PLINQ)
     Enables LINQ devs to leverage multiple cores
     Fully supports all .NET standard query operators
     Minimal impact to existing LINQ model
    var q = from p in people.AsParallel()
            where p.Name == queryInfo.Name &&
                  p.State == queryInfo.State &&
                  p.Year >= yearStart &&
                  p.Year <= yearEnd
            orderby p.Year ascending
            select p;
Parallelism Illustrations
q = from x in A where p(x) select x3;
  Intra-operator:        where p(x)
                                       … Thread 1 …

                                                        select x3

                    A
                         where p(x)                     select x3

                                       … Thread 2 …




  Inter-operator:       … Thread 1 …                  … Thread 2 …


                                                        select x3
                    A    where p(x)




                        … Thread 1 …                  … Thread 3 …



  Both composed: A       where p(x)                     select x3


                         where p(x)                     select x3

                        … Thread 2 …                  … Thread 4 …
Operator Parallelism
  Intra-operator, i.e. partitioning:
      Input to a single operator is “split” into p pieces and run in parallel
      Adjacent and nested operators can enjoy fusion
      Good temporal locality of data – each datum “belongs” to a partition
  Inter-operator, i.e. pipelining
      Operators run concurrently with respect to one another
      Can avoid “data skew”, i.e. imbalanced partitions, as can occur w/ partitioning
      Typically incurs more synchronization overhead and yields considerably worse
      locality than intra-operator parallelism, so is less attractive
  Partitioning is preferred unless there is no other choice
      For example, sometimes the programmer wants a single-CPU view, e.g.:
     foreach (x in q) a(x)
      Consumption action a for might be written to assume no parallelism
      Bad if a(x) costs more than the element production latency
         Otherwise, parallel tasks just eat up memory, eventually stopping when the bounded
         buffer fills
         But a(x) can be parallel too
Deciding Parallel Execution Strategy
  Tree analysis informs decision making:
       Where to introduce parallelism?
       And what kind? (partition vs. pipeline)
       Based on intrinsic query properties and operator costs
          Data sizes, selectivity (for filter f, what % satisfies the
          predicate?)
          Intelligent “guesses”, code analysis, adaptive feedback over
          time
  But not just parallelism, higher level optimizations too, e.g.
       Common sub-expression elimination, e.g.
          from x in X where p(f(x)) select f(x);
       Reordering operations to:
          Decrease cost of query execution, e.g. put a filter before the
          sort, even if the user wrote it the other way around
          Achieve better operator fusion, reducing synchronization cost
Partitioning Techniques
  Partitioning can be data-source sensitive
       If a nested query, can fuse existing partitions
       If an array, calculate strides and contiguous ranges (+spatial locality)
       If a (possibly infinite) stream, lazily hand out chunks
  Partitioning can be operator sensitive
       E.g. equi-joins employ a hashtable to turn an O(nm) “nested join” into O(n+m)
          Build hash table out of one data source; then probe it for matches
          Only works if all data elements in data source A with key k are in the same partition
          as those elements in data source B also with key k
          We can use “hash partitioning” to accomplish this: for p partitions, calculate k for
          each element e in A and in B, and then assign to partition based on key, e.g.
          k.GetHashCode() % p
       Output of sort: we can fuse, but restrict ordering, ordinal and key based
  Existing partitions might be repartitioned
       Can’t “push down” key partitioning information to leaves: types changed
       during stream data flow, e.g. select operator
       Nesting: join processing output of another join operator
       Or just to combat partition skew
Example: Query Nesting and Fusion
 Nesting queries inside of others is common
  We can fuse partitions
   var q1 = from x in A select x*2;
   var q2 = q1.Sum();




                                                                         +
                                                +




                                                           +


                                                                             +
               select x*2


                            select x*2




                                                            select x*2


                                                                             select x*2
                                            +


                                                    +


           I. Select                     2. Sum         3. Select +
           (alone)                       (alone)        Sum

More Related Content

What's hot

From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modelingMario Fusco
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)RichardWarburton
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...tdc-globalcode
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mark Needham
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6rohassanie
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functionsPrincess Sam
 
重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)Chris Huang
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMMario Fusco
 
The underestimated power of KeyPaths
The underestimated power of KeyPathsThe underestimated power of KeyPaths
The underestimated power of KeyPathsVincent Pradeilles
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2rohassanie
 
constructors and destructors in c++
constructors and destructors in c++constructors and destructors in c++
constructors and destructors in c++HalaiHansaika
 
Introduction to ad-3.4, an automatic differentiation library in Haskell
Introduction to ad-3.4, an automatic differentiation library in HaskellIntroduction to ad-3.4, an automatic differentiation library in Haskell
Introduction to ad-3.4, an automatic differentiation library in Haskellnebuta
 
Martin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick ReferenceMartin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick ReferenceSeung-Bum Lee
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
More on Classes and Objects
More on Classes and ObjectsMore on Classes and Objects
More on Classes and ObjectsPayel Guria
 

What's hot (20)

From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
 
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
TDC2016POA | Trilha .NET - C# como você nunca viu: conceitos avançados de pro...
 
Fp201 unit4
Fp201 unit4Fp201 unit4
Fp201 unit4
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
FP 201 - Unit 6
FP 201 - Unit 6FP 201 - Unit 6
FP 201 - Unit 6
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functions
 
重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)重構—改善既有程式的設計(chapter 9)
重構—改善既有程式的設計(chapter 9)
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
 
The underestimated power of KeyPaths
The underestimated power of KeyPathsThe underestimated power of KeyPaths
The underestimated power of KeyPaths
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2
 
Operators
OperatorsOperators
Operators
 
Writing Good Tests
Writing Good TestsWriting Good Tests
Writing Good Tests
 
constructors and destructors in c++
constructors and destructors in c++constructors and destructors in c++
constructors and destructors in c++
 
Introduction to ad-3.4, an automatic differentiation library in Haskell
Introduction to ad-3.4, an automatic differentiation library in HaskellIntroduction to ad-3.4, an automatic differentiation library in Haskell
Introduction to ad-3.4, an automatic differentiation library in Haskell
 
The STL
The STLThe STL
The STL
 
Martin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick ReferenceMartin Fowler's Refactoring Techniques Quick Reference
Martin Fowler's Refactoring Techniques Quick Reference
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
More on Classes and Objects
More on Classes and ObjectsMore on Classes and Objects
More on Classes and Objects
 

Viewers also liked (18)

LINQ to XML
LINQ to XMLLINQ to XML
LINQ to XML
 
Thinking in linq
Thinking in linqThinking in linq
Thinking in linq
 
Giving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending ExpressionsGiving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending Expressions
 
LINQ/PLINQ
LINQ/PLINQLINQ/PLINQ
LINQ/PLINQ
 
Intake 37 linq3
Intake 37 linq3Intake 37 linq3
Intake 37 linq3
 
Linq to sql
Linq to sqlLinq to sql
Linq to sql
 
C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
C# 3.0 and LINQ Tech Talk
C# 3.0 and LINQ Tech TalkC# 3.0 and LINQ Tech Talk
C# 3.0 and LINQ Tech Talk
 
Understanding linq
Understanding linqUnderstanding linq
Understanding linq
 
LINQ and LINQPad
LINQ and LINQPadLINQ and LINQPad
LINQ and LINQPad
 
Think in linq
Think in linqThink in linq
Think in linq
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
 
Introducing LINQ
Introducing LINQIntroducing LINQ
Introducing LINQ
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
 
Linq
LinqLinq
Linq
 
Of Lambdas and LINQ
Of Lambdas and LINQOf Lambdas and LINQ
Of Lambdas and LINQ
 
LINQ in Unity
LINQ in UnityLINQ in Unity
LINQ in Unity
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
 

Similar to Linq Sanjay Vyas

Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05CHOOSE
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01google
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimizedWoody Pewitt
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaJevgeni Kabanov
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersTikal Knowledge
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsChris Eargle
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?Kevin Pilch
 
Lambda expressions
Lambda expressionsLambda expressions
Lambda expressionsYuriy Seniuk
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mark Needham
 
Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#Skills Matter
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116Paulo Morgado
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
Generic Programming seminar
Generic Programming seminarGeneric Programming seminar
Generic Programming seminarGautam Roy
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scalaparag978978
 

Similar to Linq Sanjay Vyas (20)

Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
Ralf Laemmel - Not quite a sales pitch for C# 3.0 and .NET's LINQ - 2008-03-05
 
Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01Linq 090701233237 Phpapp01
Linq 090701233237 Phpapp01
 
Linq intro
Linq introLinq intro
Linq intro
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 
JBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java ProgrammersJBUG 11 - Scala For Java Programmers
JBUG 11 - Scala For Java Programmers
 
Monadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query ExpressionsMonadic Comprehensions and Functional Composition with Query Expressions
Monadic Comprehensions and Functional Composition with Query Expressions
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?
 
Lambda expressions
Lambda expressionsLambda expressions
Lambda expressions
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Generic Programming seminar
Generic Programming seminarGeneric Programming seminar
Generic Programming seminar
 
Java gets a closure
Java gets a closureJava gets a closure
Java gets a closure
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
Pragmatic Real-World Scala
Pragmatic Real-World ScalaPragmatic Real-World Scala
Pragmatic Real-World Scala
 

More from rsnarayanan

Kevin Ms Web Platform
Kevin Ms Web PlatformKevin Ms Web Platform
Kevin Ms Web Platformrsnarayanan
 
Harish Understanding Aspnet
Harish Understanding AspnetHarish Understanding Aspnet
Harish Understanding Aspnetrsnarayanan
 
Harish Aspnet Dynamic Data
Harish Aspnet Dynamic DataHarish Aspnet Dynamic Data
Harish Aspnet Dynamic Datarsnarayanan
 
Harish Aspnet Deployment
Harish Aspnet DeploymentHarish Aspnet Deployment
Harish Aspnet Deploymentrsnarayanan
 
Whats New In Sl3
Whats New In Sl3Whats New In Sl3
Whats New In Sl3rsnarayanan
 
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...rsnarayanan
 
Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlightrsnarayanan
 
Occasionally Connected Systems
Occasionally Connected SystemsOccasionally Connected Systems
Occasionally Connected Systemsrsnarayanan
 
Developing Php Applications Using Microsoft Software And Services
Developing Php Applications Using Microsoft Software And ServicesDeveloping Php Applications Using Microsoft Software And Services
Developing Php Applications Using Microsoft Software And Servicesrsnarayanan
 
Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...
Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...
Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...rsnarayanan
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Libraryrsnarayanan
 
Ms Sql Business Inteligence With My Sql
Ms Sql Business Inteligence With My SqlMs Sql Business Inteligence With My Sql
Ms Sql Business Inteligence With My Sqlrsnarayanan
 
Windows 7 For Developers
Windows 7 For DevelopersWindows 7 For Developers
Windows 7 For Developersrsnarayanan
 
What Is New In Wpf 3.5 Sp1
What Is New In Wpf 3.5 Sp1What Is New In Wpf 3.5 Sp1
What Is New In Wpf 3.5 Sp1rsnarayanan
 
Ux For Developers
Ux For DevelopersUx For Developers
Ux For Developersrsnarayanan
 
A Lap Around Internet Explorer 8
A Lap Around Internet Explorer 8A Lap Around Internet Explorer 8
A Lap Around Internet Explorer 8rsnarayanan
 

More from rsnarayanan (20)

Walther Aspnet4
Walther Aspnet4Walther Aspnet4
Walther Aspnet4
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4
 
Kevin Ms Web Platform
Kevin Ms Web PlatformKevin Ms Web Platform
Kevin Ms Web Platform
 
Harish Understanding Aspnet
Harish Understanding AspnetHarish Understanding Aspnet
Harish Understanding Aspnet
 
Walther Mvc
Walther MvcWalther Mvc
Walther Mvc
 
Harish Aspnet Dynamic Data
Harish Aspnet Dynamic DataHarish Aspnet Dynamic Data
Harish Aspnet Dynamic Data
 
Harish Aspnet Deployment
Harish Aspnet DeploymentHarish Aspnet Deployment
Harish Aspnet Deployment
 
Whats New In Sl3
Whats New In Sl3Whats New In Sl3
Whats New In Sl3
 
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...
Silverlight And .Net Ria Services – Building Lob And Business Applications Wi...
 
Advanced Silverlight
Advanced SilverlightAdvanced Silverlight
Advanced Silverlight
 
Netcf Gc
Netcf GcNetcf Gc
Netcf Gc
 
Occasionally Connected Systems
Occasionally Connected SystemsOccasionally Connected Systems
Occasionally Connected Systems
 
Developing Php Applications Using Microsoft Software And Services
Developing Php Applications Using Microsoft Software And ServicesDeveloping Php Applications Using Microsoft Software And Services
Developing Php Applications Using Microsoft Software And Services
 
Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...
Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...
Build Mission Critical Applications On The Microsoft Platform Using Eclipse J...
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
Ms Sql Business Inteligence With My Sql
Ms Sql Business Inteligence With My SqlMs Sql Business Inteligence With My Sql
Ms Sql Business Inteligence With My Sql
 
Windows 7 For Developers
Windows 7 For DevelopersWindows 7 For Developers
Windows 7 For Developers
 
What Is New In Wpf 3.5 Sp1
What Is New In Wpf 3.5 Sp1What Is New In Wpf 3.5 Sp1
What Is New In Wpf 3.5 Sp1
 
Ux For Developers
Ux For DevelopersUx For Developers
Ux For Developers
 
A Lap Around Internet Explorer 8
A Lap Around Internet Explorer 8A Lap Around Internet Explorer 8
A Lap Around Internet Explorer 8
 

Recently uploaded

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Linq Sanjay Vyas

  • 2. The LINQ Project C# VB Others… .NET Language Integrated Query Standard LINQ To SQL LINQ To XML Query LINQ To Dataset Operators LINQ To Entities <book> <title/> <author/> <year/> <price/> </book> Objects Database XML
  • 3. Language Innovations Query expressions var contacts = from c in customers where c.State == quot;WAquot; select new { c.Name, c.Phone }; Local variable type inference Lambda expressions var contacts = customers .Where(c => c.State == quot;WAquot;) .Select(c => new { c.Name, c.Phone }); Extension methods Object Anonymous initializers types 3
  • 4. Lambda Expressions public delegate bool Predicate<T>(T obj); public class List<T> { Statement context Explicitly List<T> FindAll(Predicate<T> test) , … - public typed… } Implicitly List<Customer> customers = GetCustomerList(); typed List<Customer> x = customers.FindAll( Expression delegate(Customer c) { return c.State == quot;WAquot;; } context ); List<Customer> x = customers.FindAll(c => c.State == quot;WAquot;); 4
  • 5. Lambda Expressions public delegate T Func<T>(); public delegate T Func<A0, T>(A0 arg0); public delegate T Func<A0, A1, T>(A0 arg0, A1 arg1); … Func<Customer, bool> test = c => c.State == quot;WAquot;; double factor = 2.0; Func<double, double> f = x => x * factor; Func<int, int, int> f = (x, y) => x * y; Func<int, int, int> comparer = (int x, int y) => { if (x > y) return 1; if (x < y) return -1; return 0; }; 5
  • 6. Queries Through APIs Query operators are just methods public class List<T> { public List<T> Where(Func<T, bool> predicate) , … - public List<S> Select<S>(Func<T, S> selector) , … - … } Methods compose to form queries List<Customer> customers = GetCustomerList(); List<string> contacts = customers.Where(c => c.State == quot;WAquot;).Select(c => c.Name); But what about other types? Declare operators in all collections? Type inference figures out <S> What about arrays? 6
  • 7. Queries Through APIs Query operators are static methods public static class Sequence { public static IEnumerable<T> Where<T>(IEnumerable<T> source, Func<T, bool> predicate) , … - public static IEnumerable<S> Select<T, S>(IEnumerable<T> source, Func<T, S> selector) , … - … } Huh? Customer[] customers = GetCustomerArray(); IEnumerable<string> contacts = Sequence.Select( Sequence.Where(customers, c => c.State == quot;WAquot;), c => c.Name); Want methods on IEnumerable<T> 7
  • 8. Extension Methods Extension namespace System.Query methods { public static class Sequence { public static IEnumerable<T> Where<T>(this IEnumerable<T> source, Func<T, bool> predicate) , … - public static IEnumerable<S> Select<T, S>(this IEnumerable<T> source, obj.Foo(x, y) Func<T, S> selector) , … - …  } Brings extensions XXX.Foo(obj, x, y) } into scope using System.Query; IEnumerable<string> contacts = customers.Where(c => c.State == quot;WAquot;).Select(c => c.Name); IntelliSense! 8
  • 9. Object Initializers public class Point { private int x, y; public int X { get { return x; } set { x = value; } } Field or property public int Y { get { return y; } set { y = value; } } assignments } Point a = new Point { X = 0, Y = 1 }; Point a = new Point(); a.X = 0; a.Y = 1; 9
  • 10. Object Initializers Embedded public class Rectangle objects { private Point p1 = new Point(); private Point p2 = new Point(); Read-only properties public Point P1 { get { return p1; } } public Point P2 { get { return p2; } } } Rectangle r = new Rectangle { P1 = { X = 0, Y = 1 }, P2 = { X = 2, Y = 3 } No “new Point” }; Rectangle r = new Rectangle(); r.P1.X = 0; r.P1.Y = 1; r.P2.X = 2; r.P2.Y = 3; 10
  • 11. Collection Initializers Must implement ICollection<T> List<int> powers = new List<int> { 1, 10, 100, 1000, 10000 }; List<int> powers = new List<int>(); powers.Add(1); powers.Add(10); powers.Add(100); powers.Add(1000); powers.Add(10000); 11
  • 12. Collection Initializers public class Contact { private string name; private List<string> phoneNumbers = new List<string>(); public string Name { get { return name; } set { name = value; } } public List<string> PhoneNumbers { get { return phoneNumbers; } } } List<Contact> contacts = new List<Contact> { new Contact { Name = quot;Chris Smithquot;, PhoneNumbers = { quot;206-555-0101quot;, quot;425-882-8080quot; } }, new Contact { Name = quot;Bob Harrisquot;, PhoneNumbers = { quot;650-555-0199quot; } } }; 12
  • 13. Local Variable Type Inference int i = 5; string s = quot;Helloquot;; double d = 1.0; int[] numbers = new int[] {1, 2, 3}; Dictionary<int,Order> orders = new Dictionary<int,Order>(); var i = 5; var s = quot;Helloquot;; var d = 1.0; var numbers = new int[] {1, 2, 3}; var orders = new Dictionary<int,Order>(); “var” means same type as initializer 13
  • 14. Anonymous Types public class Customer { public string Name; public Address Address; public class Contact public string Phone; { class ??? public List<Order> Orders; public string Name; { … public string Phone; Name; public string } } public string Phone; Customer c = GetCustomer(…); } Contact x = new Contact { Name = c.Name, Phone = c.Phone }; Customer c = GetCustomer(…); var x = new { Name = c.Name, Phone = c.Phone }; Projection style Customer c = GetCustomer(…); initializer var x = new { c.Name, c.Phone }; 14
  • 15. Anonymous Types var contacts = from c in customers where c.State == quot;WAquot; select new { c.Name, c.Phone }; class ??? { IEnumerable<???> public string Name; public string Phone; } var contacts = customers. .Where(c => c.State == quot;WA“) .Select(c => new { c.Name, c.Phone }); ??? foreach (var c in contacts) { Console.WriteLine(c.Name); Console.WriteLine(c.Phone); } 15
  • 16. Query Expressions Language integrated query syntax Starts with from Zero or more from or where from id in source { from id in source | where condition } [ orderby ordering, ordering, … ] Optional select expr | group expr by key orderby [ into id query ] Ends with select or Optional into group by continuation 16
  • 17. Query Expressions Queries translate to method invocations Where, Select, SelectMany, OrderBy, GroupBy from c in customers where c.State == quot;WAquot; select new { c.Name, c.Phone }; customers .Where(c => c.State == quot;WAquot;) .Select(c => new { c.Name, c.Phone }); 17
  • 18. Expression Trees public class Northwind: DataContext { public Table<Customer> Customers; public Table<Order> Orders; How does this get … remoted? } Northwind db = new Northwind(…); var query = from c in db.Customers where c.State == quot;WAquot; select c; Northwind db = new Northwind(…); Method asks for var query = db.Customers.Where(c => c.State == quot;WAquot;); expression tree public class Table<T>: IEnumerable<T> { public Table<T> Where(Expression<Func<T, bool>> predicate); … } System.Expressions. Expression<T> 18
  • 19. Expression Trees Code as Data Func<Customer, bool> test = c => c.State == quot;WAquot;; Expression<Func<Customer, bool>> test = c => c.State == quot;WAquot;; ParameterExpression c = Expression.Parameter(typeof(Customer), quot;cquot;); Expression expr = Expression.EQ( Expression.Property(c, typeof(Customer).GetProperty(quot;Statequot;)), Expression.Constant(quot;WAquot;) ); Expression<Func<Customer, bool>> test = Expression.Lambda<Func<Customer, bool>>(expr, c); 19
  • 20. Language Innovations c => c.Name Lambda expressions Extension methods static void Dump(this object o); Local variable type inference var x = 5; Object initializers new Point { x = 1, y = 2 } Anonymous types new { c.Name, c.Phone } Query expressions from … where … select Expression trees Expression<T> 20
  • 21. Why Do We Need LINQ Object-Relation mismatch • O-R Mapping tools – EJB, Hibernate Object-Hierarchical mismatch • OODBMS, Code generators Object-XML mismatch • SAX, DOM Model Complex Call Level Interfaces • ODBJ, JDBC, ADO.NET Code readability & maintenance issue
  • 22. Flavours of LINQ LINQ To Objects LINQ To Amazon LINQ To XML LINQ To Flickr LINQ To SQL LINQ To Nhibertnate LINQ To DataSets LINQ To LDAP LINQ To Entities LINQ To Google PLINQ LINQ To SharePoint
  • 23. Evolution .NET .NET .NET .NET Core IL Generics LINQ PLINQ 1.0 2.0 3.0 4.0
  • 24. Foundation LINQ Query Expression IEnumable/IQueryable Extension Methods Lambda Anonymous Types Collection Initializers Generics Static Methods Anonymous Delegates Object Initializers ICollection<T>
  • 25. LINQ to SQL Accessing data today Queries in SqlConnection c = new SqlConnection(…); quotes c.Open(); SqlCommand cmd = new SqlCommand( @quot;SELECT c.Name, c.Phone Loosely bound FROM Customers c arguments WHERE c.City = @p0quot;); cmd.Parameters.AddWithValue(quot;@p0quot;, quot;London“); DataReader dr = c.Execute(cmd); Loosely typed while (dr.Read()) { result sets string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); No compile time } checks dr.Close();
  • 26. LINQ to SQL Accessing data with LINQ Classes describe public class Customer , … - data public class Northwind : DataContext Tables are like { collections public Table<Customer> Customers; … } Strongly typed connections Northwind db = new Northwind(…); var contacts = Integrated query from c in db.Customers syntax where c.City == quot;Londonquot; select new { c.Name, c.Phone }; Strongly typed results
  • 27. LINQ to SQL Language integrated data access Maps tables and rows to classes and objects Builds on ADO.NET and .NET Transactions Mapping Encoded in attributes or external XML file Relationships map to properties Persistence Automatic change tracking Updates through SQL or stored procedures
  • 28. DataContext • A DataContext is used to scope changes made to classes defined by LINQ to SQL • A DataContext is responsible for keeping references to all LINQ to SQL classes, their properties, and foreign key relationships. • A DataContext is not meant to be kept around; we want to create a new context for every “unit of work” to avoid concurrency issues. There are multiple ways to approach this. • A DataContext is the API to the database, but at this stage it does not contain any business logic that is not implied by the database schema.
  • 29. Defining DataContext Inherit from DataContext Override Constructor(s) *Database(Name = “MyDBquot;)] public class MyDataContext : DataContext { public MyDataContext(string connString) : base(connString) { } }
  • 30. Creating DataContext Similar to SqlConnection() public static void Main() { string connString = “server=MyServer; database=MyDb”; MyDataContext context = new MyDataContext(connString); : : : }
  • 31. LINQ Queries SQL “like” Syntax Not a hack/kludge Built upon var result = from cust in context.Customers where cust.Location = “Pune” Generics select cust; Extension methods foreach (Customer c in result) { Lamdas Console.WriteLine(c.CustomerName); }
  • 32. LINQ Queries LINQ To SQL fetches data from database Populates the Table Object/EntitySet Basic LINQ semantics allows iteration
  • 33. join Query SQL “Like” join Inner join implemented as natural syntax Outer joins thru “DataShapes” var result = from c in Customers join o in Order on c.CustomerID equals o.CustomerID select new { c.CustomerName, o.OrderID } foreach (var v in result) { Console.WriteLine(v); }
  • 34. Attribute Mapping Declarative mapping No code required Map Relational to Objects *Table(Name=“prod”)+ public class Product { *Column(Name=“ProdId”, IsPrimaryKey=true)] public string ProductID; [Column] public string ProductName; }
  • 35. XML Mapping Externalized mapping Can be modified without rebuild Can be generated dynamically
  • 36. Sample xml mapping file <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <Database Name=quot;northwindquot; xmlns=quot;http://schemas.microsoft.com/linqtosql/mapping/2007quot;> <Table Name=quot;dbo.Customersquot; Member=quot;Customersquot;> <Type Name=quot;Customerquot;> <Column Name=quot;CustomerIDquot; Member=quot;CustomerIDquot; Storage=quot;_CustomerIDquot; DbType=quot;NChar(5) NOT NULLquot; CanBeNull=quot;falsequot; IsPrimaryKey=quot;truequot; /> <Column Name=quot;CompanyNamequot; Member=quot;CompanyNamequot; Storage=quot;_CompanyNamequot; DbType=quot;NVarChar(40) NOT NULLquot; CanBeNull=quot;falsequot; /> </Type> </Table> </Database>
  • 37. Code Generation Tools Attribute and XML can be manually generated CodeGen Tools VS Designer Tool Link to SQL class item Server Explorer Drag and Drop SQLMetal.exe Can generate DBML (Database Markup Language) XML Mapping File Attribute mapped code file (.cs|.vb) VLinq Visual design LINQ Queriesp://code.msdn.microsoft.com/vlinq
  • 38. LINQ Associations Mirror database relation in object collection Master-Detail mapping Data available thru Object Collections *Table(Name=“Customers”+ Class Customer { [Column] public string CustomerID; [Column]public string CompanyName; [Association(ThisKey=“CustomerID”, OtherKey=“CustomerID”+ public EntitySet<Order> orders; } *Table(Name=“Orders”)+ public class Order { [Column] public string CustomerID; [Column] public stringOrderID; }
  • 39. Association Thru XMLMapping Similar to attribute <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <Database Name=quot;northwindquot; xmlns=quot;http://schemas.microsoft.com/linqtosql/mapping/2007quot;> <Table Name=quot;dbo.Customersquot; Member=quot;Customersquot;> <Type Name=quot;Customersquot;> <Column Name=quot;CustomerIDquot; Member=quot;CustomerIDquot; Storage=quot;_CustomerIDquot; DbType=quot;NChar(5) NOT NULLquot; CanBeNull=quot;falsequot; IsPrimaryKey=quot;truequot; /> <Column Name=quot;CompanyNamequot; Member=quot;CompanyNamequot; Storage=quot;_CompanyNamequot; DbType=quot;NVarChar(40) NOT NULLquot; CanBeNull=quot;falsequot; /> <Association Name=quot;FK_Orders_Customersquot; Member=quot;Ordersquot; Storage=quot;_Ordersquot; ThisKey=quot;CustomerIDquot; OtherKey=quot;CustomerIDquot;/> </Type> </Table> <Table Name=quot;dbo.Ordersquot; Member=quot;Ordersquot;> <Type Name=quot;Ordersquot;> <Column Name=quot;OrderIDquot; Member=quot;OrderIDquot; Storage=quot;_OrderIDquot; DbType=quot;Int NOT NULL IDENTITYquot; IsPrimaryKey=quot;truequot; IsDbGenerated=quot;truequot; AutoSync=quot;OnInsertquot; /> <Column Name=quot;CustomerIDquot; Member=quot;CustomerIDquot; Storage=quot;_CustomerIDquot; DbType=quot;NChar(5)quot; /> <Column Name=quot;OrderDatequot; Member=quot;OrderDatequot; Storage=quot;_OrderDatequot; DbType=quot;DateTimequot; /> </Type> </Table> </Database>
  • 40. Call StoreProcedures SPs can be mapped thru attributes or XML Call semantics similar to tables Supports parameter passing (in/out) Existing Entity behaviour can be changed to use SPs instead of SQL
  • 41. LINQ to Entities using(AdventureWorksDB aw = new AdventureWorksDB(Settings.Default.AdventureWorks)) { Query<SalesPerson> newSalesPeople = aw.GetQuery<SalesPerson>( quot;SELECT VALUE sp quot; + quot;FROM AdventureWorks.AdventureWorksDB.SalesPeople AS sp quot; + quot;WHERE sp.HireDate > @datequot;, new QueryParameter(quot;@datequot;, hireDate)); foreach(SalesPerson p in newSalesPeople) { Console.WriteLine(quot;{0}t{1}quot;, p.FirstName, p.LastName); } } using(AdventureWorksDB aw = new AdventureWorksDB(Settings.Default.AdventureWorks)) { var newSalesPeople = from p in aw.SalesPeople where p.HireDate > hireDate select p; foreach(SalesPerson p in newSalesPeople) { Console.WriteLine(quot;{0}t{1}quot;, p.FirstName, p.LastName); } }
  • 43. Declarative Data Parallelism Parallel LINQ-to-Objects (PLINQ) Enables LINQ devs to leverage multiple cores Fully supports all .NET standard query operators Minimal impact to existing LINQ model var q = from p in people.AsParallel() where p.Name == queryInfo.Name && p.State == queryInfo.State && p.Year >= yearStart && p.Year <= yearEnd orderby p.Year ascending select p;
  • 44. Parallelism Illustrations q = from x in A where p(x) select x3; Intra-operator: where p(x) … Thread 1 … select x3 A where p(x) select x3 … Thread 2 … Inter-operator: … Thread 1 … … Thread 2 … select x3 A where p(x) … Thread 1 … … Thread 3 … Both composed: A where p(x) select x3 where p(x) select x3 … Thread 2 … … Thread 4 …
  • 45. Operator Parallelism Intra-operator, i.e. partitioning: Input to a single operator is “split” into p pieces and run in parallel Adjacent and nested operators can enjoy fusion Good temporal locality of data – each datum “belongs” to a partition Inter-operator, i.e. pipelining Operators run concurrently with respect to one another Can avoid “data skew”, i.e. imbalanced partitions, as can occur w/ partitioning Typically incurs more synchronization overhead and yields considerably worse locality than intra-operator parallelism, so is less attractive Partitioning is preferred unless there is no other choice For example, sometimes the programmer wants a single-CPU view, e.g.: foreach (x in q) a(x) Consumption action a for might be written to assume no parallelism Bad if a(x) costs more than the element production latency Otherwise, parallel tasks just eat up memory, eventually stopping when the bounded buffer fills But a(x) can be parallel too
  • 46. Deciding Parallel Execution Strategy Tree analysis informs decision making: Where to introduce parallelism? And what kind? (partition vs. pipeline) Based on intrinsic query properties and operator costs Data sizes, selectivity (for filter f, what % satisfies the predicate?) Intelligent “guesses”, code analysis, adaptive feedback over time But not just parallelism, higher level optimizations too, e.g. Common sub-expression elimination, e.g. from x in X where p(f(x)) select f(x); Reordering operations to: Decrease cost of query execution, e.g. put a filter before the sort, even if the user wrote it the other way around Achieve better operator fusion, reducing synchronization cost
  • 47. Partitioning Techniques Partitioning can be data-source sensitive If a nested query, can fuse existing partitions If an array, calculate strides and contiguous ranges (+spatial locality) If a (possibly infinite) stream, lazily hand out chunks Partitioning can be operator sensitive E.g. equi-joins employ a hashtable to turn an O(nm) “nested join” into O(n+m) Build hash table out of one data source; then probe it for matches Only works if all data elements in data source A with key k are in the same partition as those elements in data source B also with key k We can use “hash partitioning” to accomplish this: for p partitions, calculate k for each element e in A and in B, and then assign to partition based on key, e.g. k.GetHashCode() % p Output of sort: we can fuse, but restrict ordering, ordinal and key based Existing partitions might be repartitioned Can’t “push down” key partitioning information to leaves: types changed during stream data flow, e.g. select operator Nesting: join processing output of another join operator Or just to combat partition skew
  • 48. Example: Query Nesting and Fusion  Nesting queries inside of others is common  We can fuse partitions  var q1 = from x in A select x*2;  var q2 = q1.Sum(); + + + + select x*2 select x*2 select x*2 select x*2 + + I. Select 2. Sum 3. Select + (alone) (alone) Sum