Tuesday, May 18, 2010

What is Linq,DLinq & XLinq?

The Linq project offers querying features integrated right into programming languages. This will allow executing strongly-typed queries on sources such as databases, XML documents or even object graphs in memory. This technology relies on innovations on programming languages like C# 3 or VB.NET 9, and it will be ported to other .NET languages like Delphi.

DLinq is an extension to Linq that allows querying a database (only SQL Server for the moment) and do object-relational mapping.
XLinq is an extension to Linq that allows querying XML documents, as well as creating or transforming XML.

Like for DLinq,
Here is what is performed in each case:

We just execute a simple query: return
cst in _db.Customers
where cst.Country == country
select cst;
we can map through the all records using IEnumerable or IQueryable object.

Like for XLinq,

  // Load XML
  var webCustomers = XElement.Parse(xmlData);

  // Create view
  var result = from customer in customers, webCustomer in webCustomers.Elements()
      where customer.CustomerID == webCustomer.Attribute("ID").Value
      select new {
        ID = customer.CustomerID,
        Name = customer.CompanyName,
        EMail = webCustomer.Attribute("EMail").Value,
        WebSite = webCustomer.Attribute("WebSite").Value};

  // Display


New features of c# framework 4.0

New features of c# framework 4.0

1]Dynamic:Now you can create dynamic objects and let their types be determined at run time.

2]Covariance and Contravariance:Variance on generic type parameters in interfaces and delegates is another important feature of this release. It doesn’t add much new functionality, but rather makes things work as you expected them to in the first place. The major advantage is hidden in this simple line, which didn’t compile until C# 4.0

3]Optional (or Default) Parameters:Now you can assign a default value to a parameter right within the method declaration. The user of the method can either pass a value or simply skip the argument. In the latter case, the default value is passed to the method.

4]Named Arguments:The order of parameters in a method declaration and the order of arguments you pass when calling the method don’t need to match anymore. You can provide arguments in any order you like by specifying parameter names in a method call. This might also improve the readability of your code.

5]Improved COM Interop:The introduction of the dynamic keyword, optional parameters and named arguments enables improvement of COM interop.

Here are some links for further reading:

"Please give me your valuable comments to improve my knowledge :) " 

    What is basic difference between WCF and webservices?

    There are basically few difference which makes WCF more powerful that to the asp.net webservices,

    1] WCF services are self hosting means they dont need IIS setup
    2] WCF works on DatacontractSerializer while  web services works on xml serializer
    3] WCF can handle private properties and fields
    4] The DatacontractSerializer can translate the HashTable into XML.


    "Please give me your valuable comments to improve my knowledge :) "

    Monday, May 17, 2010

    Tell me which is faster VB or C#?

    Let me tell you brief story about the reason behind this question, one of my junior colleague has just joined my company, he always have new questions in mind, so he picked me to ask this question,

    "Tell me which is faster VB or C#?", i got dumb what to say but then i end up with c# without any reason because i am working on c# since last 3 years (without any reason),

    I search up many posts but some of them saying c# and some of them were saying VB,
    I end up with zero for one day then with some more brainstorming i come with conclusion:

    "Language can be any but Finally your code going to complied to IL which is same for VB and C#,
    So it depends on how you have coded and what amount of complexity have added"


    "Please give me your valuable comments to improve my knowledge :) "

    Dynamic type in c# 4.0

    Due to the languages like pyhton,ruby and growing technologies Microsoft introduced a new keyword name Dynamic in c# 4.0, we have var keyword for somehow same purpose.

    The dynamic capabilities of C# 4 are part of the Dynamic Language Runtime (DLR). The DLR is
    a set of services that is added to the CLR to allow the addition of dynamic languages such as Ruby and Python. It also allows C# to take on some of the same dynamic capabilities that these dynamic languages have.

    There is a version of the DLR that is open source and resides on the CodePlex web site. This
    same version is included with the .NET 4 Framework, with some additional support for language

    In the .NET Framework, the DLR is found in the System.Dynamic namespace as well as a few
    additional classes in the System.Runtime.CompilerServices namespace.
    IronRuby and IronPython, which are open source versions of the Ruby and Python languages, use the DLR. Silverlight also uses the DLR. It ’ s possible to add scripting capabilities to your applications by hosting the DLR. The scripting runtime allows you to pass variables to and from the script.

    The Dynamic type will allow developer to assign any datatype instance without worrying about casting.

    dynamic dn = new Person();


    1] You cant query dynamic variable using Linq,
    2] Even not supports Extension methods


    "Please give me your valuable comments to improve my knowledge :) "