Window Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Thursday, 13 March 2008

Simple LINQ Demo

Posted on 09:27 by Unknown

Everyone here now must be aware of the revolutionary model of Data Connectivity and Data Handling. I just saw few days ago some articles posted on Internet but for newbie like me who are just came out from college in such big Developer community. Its very difficult to judge these days what to learn, when to learn and from whom to learn..isn't it..? ;-)

I was shocked firstly when I saw few Videos and Articles on LINQ , I done lots of C programming in My MCM Course for more than a year, but I never query any collection or string. I think future is bright for Data Connectivity, Right now I everyday have debate in my company over the MVC (Model View Controller) pattern of Data connectivity, Some says its quite slow because of many internal trips in Classes, Some says its the only best, but what I observe is Web Service is superfast!!

Humm..And one last thing..Don't try this on Visual Studio 05 ;-) .. This VS08 is awesome!!

Where here my code goes which is basically a C# console application, I can say that these code snippets can fall under category of LINQ to Objects, I am using IEnum

Make sure before you start coding that you have following namespace included

System.Linq and System.Linq.Expressions

static void Main(string[] args)

{

string[] friends = { "Vikram", "Chaitanya", "Ameya", "Sid" };

//Normal declaration of string which contains few names for example

//Below is Query which we are executing over our pre-defined collection

IEnumerable<string> firstname = from v in friends

where v.Contains("i") && v.Length <7

orderby v ascending

select v;

//Below is plain simple loop which will just print the query result

foreach (string name in firstname )

{

    Console.WriteLine(name);

}

//Still I am not forgetting getch() in C

Console.ReadLine();

}

Some of the query combination you can try on with && and || operator

  1. Using "And" operator i.e &&

    IEnumerable<string> firstname = from v in friends

where v.Contains("i") && v.Length <7

orderby v ascending

select v;

  1. Using "Or" operator i.e ||

    IEnumerable<string> firstname = from v in friends

where v.Contains("i") || v.Length <7

orderby v ascending

select v;

Well..I hope this will give some idea how LINQ looks like..will do now LINQ to XML soon.

Vikram.

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • First Windows Phone 7 update February 2011 - Small update but Big start
    After tons of rumors and set of predictions on Windows Phone 7 all over Internet, Microsoft came up with first Windows Phone 7 minor update ...
  • The little Story of “I Unlock Joy” event by Microsoft and Pune User Group
      This post is about recent “I Unlock Joy” event happened in Pune which was conducted by Microsoft and Pune User Group. Little History : ...
  • Silverlight 2 : Theming from Silverlight 2 Toolkit
    It’s now time to put on some cool Themes to your Silverlight 2 Controls. I have already talked about Silverlight toolkit in my last post, ...
  • DeepZoom with PhotoZoom and Silverlight.live.com
    I have already wrote article on How to build DeepZoom with DeepZoom Composer, I know after that another version of DeepZoom came up, but cha...
  • Silverlight 5 : Platform Invoke (PInvoke) in Silverlight
      Two days back Microsoft announced availability of Silverlight 5 RC,I encourage you to download bits from here , My friend Pete Brown alr...
  • Silverlight On Mobile : Windows Phone 7 Splash Screen and Customization
    After talking about 3D capabilities on Windows Phone 7 using Silverlight in last article , Now I am moving ahead with small but equally impo...
  • Silverlight, HTML5 & Windows 8 : Where we are heading to ?
    This is not the post or yet another post on most happening debate of Silverlight and HTML5, This is just a visit to all of them to realize t...
  • Silverlight 3 : Out Of Browser
    I have already written an article over Silverlight Out Of Browser functionality few months back ( http://pendsevikram.blogspot.com/2009/04/s...
  • Mango : Using DeviceStatus in Windows Phone 7.1
    First of all “Thank You” for your wonderful response and comments on my last article on Silverlight Vs HTML5 ,I hope you like the points I ...
  • Share Status and Link on Socials in Windows Phone
      Hope you all doing good.Sorry for the great delay here,I am almost working for all 7 days in week and that too on SQL Server – SSIS whic...

Blog Archive

  • ►  2013 (4)
    • ►  August (1)
    • ►  April (3)
  • ►  2012 (4)
    • ►  July (1)
    • ►  March (2)
    • ►  January (1)
  • ►  2011 (24)
    • ►  December (1)
    • ►  September (4)
    • ►  August (2)
    • ►  July (1)
    • ►  June (4)
    • ►  May (3)
    • ►  April (3)
    • ►  March (1)
    • ►  February (4)
    • ►  January (1)
  • ►  2010 (21)
    • ►  December (1)
    • ►  November (2)
    • ►  October (3)
    • ►  September (2)
    • ►  August (4)
    • ►  July (5)
    • ►  May (1)
    • ►  April (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2009 (49)
    • ►  December (1)
    • ►  November (5)
    • ►  October (2)
    • ►  September (1)
    • ►  August (5)
    • ►  July (5)
    • ►  June (1)
    • ►  May (5)
    • ►  April (5)
    • ►  March (9)
    • ►  February (4)
    • ►  January (6)
  • ▼  2008 (43)
    • ►  December (3)
    • ►  November (9)
    • ►  October (7)
    • ►  September (4)
    • ►  August (2)
    • ►  July (3)
    • ►  June (4)
    • ►  May (3)
    • ▼  March (3)
      • JavaScript Debugging in Visual Studio 2005
      • Simple LINQ Demo
      • Implementing Ajax : With UpdateProgress
    • ►  February (5)
Powered by Blogger.

About Me

Unknown
View my complete profile