You must Sign In to post a response.
  • Category: .NET

    what is linq in .net?

    what is linq in .net?
  • #300473
    LINQ fundamentally is about integrating query operations into the .NET platform in a comprehensive and open manner. It's also about providing a unified way for you to query across any kind of data that you have in your program, whether it's relational, objects or XML.

    Watch the video in the following link if you need more info.
    http://weblogs.asp.net/scottgu/archive/2007/01/28/video-using-linq-with-asp-net-in-vs-orcas-part-1.aspx

  • #300475
    LINQ - Language INtergrated Querry pronounced as LINK
    A technology with capaplities to execute querries on objects.which will return an collection object.

    It's a .NET Framework component that adds querying capabilities to .NET languages like VB.net,C#.net etc using a syntax similar to that of SQL.

    There are set of query operators defined by LINQ are provided to the user as the Standard Query Operator API (SQO API).
    Some of The query operators supported are
    a)Select / SelectMany
    b)Where
    c)Sum / Min / Max / Average / Aggregate
    d)Join / GroupJoin
    e)Take / TakeWhile
    f)OrderBy / ThenBy
    and many More.


    If you try google with keywords '101 LINQ Samples' you will find a site related to it. Which will prove benificial for learners,

    Regards Hefin Dsouza

    Regards Hefin Dsouza

  • #300531
    LINQ stands for “Language Integrated QUery." LINQ fundamentally is about integrating query operations into the .NET platform in a comprehensive and open manner. It's also about providing a unified way for you to query across any kind of data that you have in your program, whether it's relational, objects or XML. This, we believe, will represent a tectonic shift in the way that VB programmers will work with data. The possibilities that having query capabilities always available right at your fingertips, regardless of the type of data you're working with, are immense and will fundamentally alter the way people program.

    The core of LINQ is a set of API patterns. I say “patterns" instead of “interfaces" or “classes" because we want to maintain maximum flexibility in our ability to provide querying for any kind of data, regardless of whether it has a particular object model or interface implemented. These API patterns specify how an object model can become “queryable," and they cover all the basic query operations that we know and love: projection (select), filter (where), grouping (group by), ordering (order by), joining (join), etc. By implementing this API pattern, any data provider on .NET can become queryable. There is also a lot of flexibility as to how a data provider can become flexible — i.e., whether it wants to delegate most of the work on querying or whether it wants to do all the work itself.

    (It's also important to note that these patterns are fully compatible with .NET 2.0 and require no additional platform features. They're totally implementable in VS 2005, so you won't need a new CLR to use them.)

    We will also be providing three implementations of the LINQ API patterns that cover 95% of the types of data that people need to query: relational, object and XML. First, we will provide a set of “standard query operators" that will make the interface IEnumerable(Of T), the fundamental collection interface on the .NET platforms, queryable. Second, we will provide a component called “DLinq" that implements a query-enabled object/relational mapping service which allows querying over remote relational data. And third, we will provide a component called “XLinq" that implements a very lightweight, query-enabled XML DOM. By hitting each element of the ROX equation, we believe we will provide a query solution for most situations right out of the box.

    Now we get to the languages, which is where the fun really starts. Any .NET-enabled language is free to build extra language support on top of the LINQ API patterns, and VB and C# have already begun to do so. Although you are welcome to call the lower-level APIs directly if you like, VB will provide a set of “query comprehensions" that provide a very natural, SQL-like syntax on top of the LINQ APIs. For example, if you have an array of Customer objects, you can write a query that looks like this:

    Dim custs() As Customer = ...Dim waCusts = Select c.Name, c.City From c In custs Where c.State = “WA"
    This high-level syntax then compiles down to calls to the standard LINQ APIs. This means that you can learn a very simple, natural query language that then applies across any component that is query-enabled, including the standard query operators, DLinq, and XLinq. (C# will also be providing a high level syntax that is similar, but not the same. We'll be talking about some of the differences as we dig more into the syntax.)

    So far we've been discussing things that are general to the platform or apply to both VB and C# (modulo the differences in approaches). However, there are a several things that are specific to VB that play a role in the LINQ project.

    The first is that we've been working on several features that we believe will make working with dynamic data easier. By “dynamic data," I mean data whose schema is flexible, malleable or likely to change. The best example of this is XML data — although there is plenty of highly schematized XML out there, there is a vast sea of XML data for which no schema information exists or for which there is no 100% solid schema (RSS is a perfect example). For languages that understand only static type information, this means that when you deal with dynamic data, you frequently have to do a lot of extra work to access information, for example you end up writing:

    XElement ord = ...;int amount = (int)ord.Element(“amount");
    instead of something much more natural like:

    Dim ord As OrderDim amount As Integer = ord.amount
    So, what we've been doing is taking VB's historical embrace of dynamic binding (aka “late binding") and extending it further to make working with dynamic data such as XML and relational much easier.

    The other major thing we've been working on is making it much more natural to read and produce XML data. XML has become the lingua franca of the Internet and XML should be as easy as possible to work with. We've been exploring ways to take the XLinq API and add syntax that looks and feels very natural, but still compiles down to regular API calls:

    Dim orderAmount As Integer = 10Dim order As XElement = _ Dim orderDate As Date = CDate(order.@date)
    As you can see, the LINQ project is extremely ambitious and this blog entry has just scratched the surface. In conjunction with the PDC, we are releasing a bunch of preliminary information about LINQ and about VB LINQ support specifically. There are documents describing in more detail a lot of what I discussed here today, as well as pointers to preliminary bits. (I would emphasize that word “preliminary" as in “lots of things don't work yet." We expect to roll out new bits regularly as functionality comes online.) I encourage everyone who's interested to check them out and then check back here regularly

  • #300593
    Creating your first ASP.NET page using LINQ
    Create a new page called Step1.aspx. Within the .aspx page add a GridView control like so:
    <%@ Page Language="C#" CodeFile="Step1.aspx.cs" Inherits="Step1" %>
    <html>
    <body>
    <form id="form1" runat="server">
    <div>
    <h1>City Names</h1>
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
    </div>
    </form>
    </body>
    </html>
    Within the code-behind file we'll then write the canonical “hello world" LINQ sample – which involves searching and ordering a list of strings:
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Query;
    public partial class Step1 : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    string[] cities = { "London", "Amsterdam", "San Francisco", "Las Vegas",
    "Boston", "Raleigh", "Chicago", "Charlestown",
    "Helsinki", "Nice", "Dublin" };
    GridView1.DataSource = from city in cities
    where city.Length > 4
    orderby city
    select city.ToUpper();
    GridView1.DataBind();
    }
    }
    In the above sample I've created an array of strings listing the cities I've visited from Jan->May of this year. I'm then using a LINQ query expression against the array. This query expression returns all cities where the city name is greater than 4 characters, and orders the result in alphabetical order and transforms those city names into upper case.
    LINQ queries return results of type: IEnumerable<T> -- where <T> is determined by the object type of the “select" clause. In the above sample “city" is a string, so the type-safe result is a generics based collection like so:
    IEnumerable<string> result = from city in cities
    where city.Length > 4
    orderby city
    select city.ToUpper();
    Because ASP.NET controls already support databinding to any IEnumerable collection, we can easily assign this LINQ query result to the GridView and call its DataBind() method to generate this page output result:


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.