Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

advantages on LINQ

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thirumurugan.ga@gmail.com - 09 Jan 2008 09:00 GMT
I want to know advantages on LINQ
Lasse Vågsæther Karlsen - 09 Jan 2008 09:23 GMT
> I want to know advantages on LINQ

That's a very vague question.

For one, you got a simplified syntax for querying enumerable data
sources of various types.

Signature

Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/

Nicholas Paldino [.NET/C# MVP] - 09 Jan 2008 15:45 GMT
As Lasse says, that is a vague question, but there are some definite
advantages that can be pointed to.

   The biggest one is that you can now structure queries in your code which
are compile-time checked, regardless of the back end data source (so if you
are using LINQ-to-SQL, then you are going to get compile-time checking on
your queries, instead of seeing it at runtime with a query string).

   If you are using LINQ-to-Objects, then a big advantage is that you can
create complex queries in a simple manner which were previously very
difficult.

   For example, say you want to get all the declared methods on a type
which are generic which you want to run some processing on.  In .NET 2.0,
you would do this:

// Get the methods.  Assume type is of type Type.
IEnumerable<MethodInfo> methods = type.GetMethods();

// Cycle.
foreach (MethodInfo methodInfo in methods)
{
   // Check to see if the method is generic.
   if (methodInfo.IsGeneric)
   {
       // Continue processing.
   }
}

   In .NET 3.5/C# 3.0, you can do this:

// Generate the query.
IEnumerable<MethodInfo> methods =
   from methodInfo in type.GetMethods()
   where methodInfo.IsGeneric
   select methodInfo;

// Process the methods.
foreach (MethodInfo methodInfo in methods)
{
   // Process.
}

   Subsequently, you could also do this, which is even simpler, in my
opinion:

// Get the methods.
IEnumerable<MethodInfo> methods = type.GetMethods().Where(methodInfo =>
methodInfo.IsGeneric);

// Process.
foreach (MethodInfo methodInfo in methods)
{
   // Process.
}

   Two big wins, IMO.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I want to know advantages on LINQ
Mythran - 09 Jan 2008 16:34 GMT
>    In .NET 3.5/C# 3.0, you can do this:
>
[quoted text clipped - 24 lines]
>
>    Two big wins, IMO.

Man, I wish I was working for a company that allowed me to use .Net
3.5/C#3.0.  Currently, we are still using the 1.1 framework and VB.Net...(I
know C# and VB.Net but they won't allow us to use C#).

Sucks for me!

:)

Mythran
Michael Starberg - 11 Jan 2008 15:26 GMT
> Sucks for me!
>
> :)
>
> Mythran

GROUPHUG!

I feel so sorry for you...
Maybe you should quit your job and find a better employer?

- Michael Starberg

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.