Labels

Wednesday, July 22, 2009

LINQ to SQL - Operators

Hi,

 

There are two type of Operators.

 

-          Deferred

-          Non-Deferred

 

 

 

string[] presidents = {

"Adams", "Arthur", "Buchanan", "Bush", "Carter", "Cleveland",

"Clinton", "Coolidge", "Eisenhower", "Fillmore", "Ford", "Garfield",

"Grant", "Harding", "Harrison", "Hayes", "Hoover", "Jackson",

"Jefferson", "Johnson", "Kennedy", "Lincoln", "Madison", "McKinley",

"Monroe", "Nixon", "Pierce", "Polk", "Reagan", "Roosevelt", "Taft",

"Taylor", "Truman", "Tyler", "Van Buren", "Washington", "Wilson"};

 

 

 

Deferred Operators

 

Restriction           

Where

 

public static IEnumerable<T> Where<T>(this IEnumerable<T> source,Func<T, bool> predicate);

public static IEnumerable<T> Where<T>(this IEnumerable<T> source,Func<T, int, bool> predicate);

 

Projection           

Select

SelectMany

 

public static IEnumerable<S> Select<T, S>(this IEnumerable<T> source,Func<T, S> selector);

public static IEnumerable<S> Select<T, S>(this IEnumerable<T> source,Func<T, int, S> selector);

 

public static IEnumerable<S> SelectMany<T, S>(this IEnumerable<T> source,Func<T, IEnumerable<S>> selector);

public static IEnumerable<S> SelectMany<T, S>(this IEnumerable<T> source,Func<T, int, IEnumerable<S>> selector);.

 

Partitioning           

Skip

SkipWhile

Take

TakeWhile

 

public static IEnumerable<T> Skip<T>(this IEnumerable<T> source,int count);

public static IEnumerable<T> SkipWhile<T>(this IEnumerable<T> source,Func<T, bool> predicate);

public static IEnumerable<T> SkipWhile<T>(this IEnumerable<T> source,Func<T, int, bool> predicate);

 

 

Concatenation           

Concat

 

public static IEnumerable<T> Concat<T>(this IEnumerable<T> first,IEnumerable<T> second);

Ordering           

OrderBy

OrderByDescending

Reverse

ThenBy

ThenByDescending

 

 

Join                 

Join

GroupJoin

 

public static IEnumerable<V> Join<T, U, K, V>(this IEnumerable<T> outer,IEnumerable<U> inner,Func<T, K> outerKeySelector,Func<U, K> innerKeySelector, Func<T, U, V> resultSelector);

 

public static IEnumerable<V> GroupJoin<T, U, K, V>(this IEnumerable<T> outer,IEnumerable<U> inner,Func<T, K> outerKeySelector,Func<U, K> innerKeySelector,Func<T, IEnumerable<U>, V> resultSelector);

 

Grouping           

GroupBy

 

 

Set                  

Distinct

Except

Intersect

Union

 

public static IEnumerable<T> Distinct<T>(this IEnumerable<T> source);

public static IEnumerable<T> Union<T>(this IEnumerable<T> first,IEnumerable<T> second);

public static IEnumerable<T> Intersect<T>(this IEnumerable<T> first,IEnumerable<T> second);

public static IEnumerable<T> Except<T>(this IEnumerable<T> first,IEnumerable<T> second);

Conversion           

Cast

OfType

 

public static IEnumerable<T> Cast<T>(this IEnumerable source);

public static IEnumerable<T> OfType<T>(this IEnumerable source);

public static IEnumerable<T> AsEnumerable<T>(this IEnumerable<T> source);

Element                       

DefaultIfEmpty

ElementAt

ElementAtOrDefault

First

FirstOrDefault

Last

LastOrDefault

Single

SingleOrDefault

 

 

public static T First<T>(this IEnumerable<T> source);

public static T First<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T FirstOrDefault<T>(this IEnumerable<T> source);

public static T FirstOrDefault<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T Last<T>(this IEnumerable<T> source);

public static T Last<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T LastOrDefault<T>(this IEnumerable<T> source);

public static T LastOrDefault<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T Single<T>(this IEnumerable<T> source);

public static T Single<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T SingleOrDefault<T>(this IEnumerable<T> source);

public static T SingleOrDefault<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T ElementAt<T>(this IEnumerable<T> source,int index);

public static T ElementAtOrDefault<T>(this IEnumerable<T> source,int index);

 

Generation

Empty

Range

Repeat

 

public static IEnumerable<T> Empty<T>();

public static IEnumerable<int> Range(int start,int count);

public static IEnumerable<T> Repeat<T>(T element,int count);

 

 

 

Non Deferred Operators

 

Conversion

ToArray

ToDictionary

ToList

ToLookup

 

public static T[] ToArray<T>(this IEnumerable<T> source);

public static List<T> ToList<T>(this IEnumerable<T> source);

 

public static Dictionary<K, T> ToDictionary<T, K>(this IEnumerable<T> source,Func<T, K> keySelector);

public static Dictionary<K, T> ToDictionary<T, K>(this IEnumerable<T> source,Func<T, K> keySelector,IEqualityComparer<K> comparer);

 

public static Dictionary<K, E> ToDictionary<T, K, E>(this IEnumerable<T> source,Func<T, K> keySelector,Func<T, E> elementSelector);

public static Dictionary<K, E> ToDictionary<T, K, E>(this IEnumerable<T> source,Func<T, K> keySelector,Func<T, E> elementSelector,IEqualityComparer<K> comparer);

 

public static ILookup<K, T> ToLookup<T, K>(this IEnumerable<T> source,Func<T, K> keySelector);

public static ILookup<K, T> ToLookup<T, K>(this IEnumerable<T> source,Func<T, K> keySelector,IEqualityComparer<K> comparer);

public static ILookup<K, E> ToLookup<T, K, E>(this IEnumerable<T> source,Func<T, K> keySelector,Func<T, E> elementSelector);

public static ILookup<K, E> ToLookup<T, K, E>(this IEnumerable<T> source,Func<T, K> keySelector,Func<T, E> elementSelector,IEqualityComparer<K> comparer);

 

 

Equality

SequenceEqual

 

public static bool SequenceEqual<T>(this IEnumerable<T> first,IEnumerable<T> second);

public static bool SequenceEqual<T>(this IEnumerable<T> first,IEnumerable<T> second,IEqualityComparer<T> comparer);

 

Element

First

FirstOrDefault

Last

LastOrDefault

Single

SingleOrDefault

ElementAt

ElementAtOrDefault

 

public static T First<T>(this IEnumerable<T> source);

public static T First<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T FirstOrDefault<T>(this IEnumerable<T> source);

public static T FirstOrDefault<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T Last<T>(this IEnumerable<T> source);

public static T Last<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T LastOrDefault<T>(this IEnumerable<T> source);

public static T LastOrDefault<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T Single<T>(this IEnumerable<T> source);

public static T Single<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T SingleOrDefault<T>(this IEnumerable<T> source);

public static T SingleOrDefault<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static T ElementAt<T>(this IEnumerable<T> source,int index);

public static T ElementAtOrDefault<T>(this IEnumerable<T> source,int index);

 

Quantifiers

Any

All

Contains

 

public static bool Any<T>(this IEnumerable<T> source);

public static bool Any<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static bool All<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static bool Contains<T>(this IEnumerable<T> source,T value);

public static bool Contains<T>(this IEnumerable<T> source,T value,IEqualityComparer<T> comparer);

 

Aggregate

Count

LongCount

Sum

Min

Max

Average

Aggregate

 

public static int Count<T>(this IEnumerable<T> source);

public static int Count<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static long LongCount<T>(this IEnumerable<T> source);

public static long LongCount<T>(this IEnumerable<T> source,Func<T, bool> predicate);

 

public static Numeric Sum(this IEnumerable<Numeric> source);

public static Numeric Sum<T>(this IEnumerable<T> source,Func<T, Numeric> selector);

 

public static Numeric Min(this IEnumerable<Numeric> source);

public static T Min<T>(this IEnumerable<T> source);

public static Numeric Min<T>(this IEnumerable<T> source,Func<T, Numeric> selector);

public static S Min<T, S>(this IEnumerable<T> source,Func<T, S> selector);

 

public static Numeric Max(this IEnumerable<Numeric> source);

public static T Max<T>(this IEnumerable<T> source);

public static Numeric Max<T>(this IEnumerable<T> source,Func<T, Numeric> selector);

public static S Max<T, S>(this IEnumerable<T> source,Func<T, S> selector);

 

public static Result Average(this IEnumerable<Numeric> source);

public static Result Average<T>(this IEnumerable<T> source,Func<T, Numeric> selector);

 

public static T Aggregate<T>(this IEnumerable<T> source,Func<T, T, T> func);

public static U Aggregate<T, U>(this IEnumerable<T> source,U seed,Func<U, T, U> func);

 

 

 

Thanks & Regards,

Arun Manglick || Senior Tech Lead

 

Monday, July 20, 2009

Web Forms And ASP.NET MVC

Hi,

 

Based on server controls, ASP.NET allows developers to build real-world Web sites and applications with minimal HTML and JavaScript skills.

The whole point of ASP.NET is productivity, achieved thru powerful set of server controls, user controls, postback events, viewstate, forms authentication, and intrinsic objects.

The model behind ASP.NET is called Web Forms. ASP.NET allows developers to build real-world Web sites and applications with minimal HTML and JavaScript skills.

 

So why did Microsoft release "another" ASP.NET framework, called ASP.NET MVC?  To read more use below.

 

MSDN article on – ‘Comparing Web Forms and ASP.NET MVC’ - Link

Please go thru the reference to read out in detail. However below are the highlights on this topic.

 

Drawbacks of Web Forms

 

-          Separation of concerns (SoC) has not been a natural fit with the Web Forms paradigm.

-          ASP.NET Web Forms is based on a monolithic runtime environment that can be extended, to some extent, but it is Not A Pluggable And Flexible system. It's nearly impossible to test an ASP.NET application without spinning up the whole runtime.

-          Abstraction from HTML is a serious issue as it hinders accessibility, browser compatibility, and integration with popular JavaScript frameworks like jQuery, Dojo, and PrototypeJS

-          The postback model that defaults each page to post to itself, results in Lower Rank For Search Engines to rank ASP.NET pages high. Search engines and spiders work better with links with parameters, better if rationalized to human-readable strings. The postback model goes in the opposite direction.

-          Also, an excessively large viewstate is problematic because the keyword the rank is based on may be located past the viewstate, and therefore far from the top of the document. Some engines recognize a Lower Rank in this case.

 

 

 

Benefits of ASP.NET MVC

 

-          With ASP.NET MVC, you rediscover the good old taste of the Web—stateless behavior, full control over every single bit of HTML, total script and CSS freedom.

-          ASP.NET MVC is a completely new framework for building ASP.NET applications, designed from the ground up with SoC and Testability in mind.

-          When you write an ASP.NET MVC application, you think in terms of controllers and views. You make your decisions about how to pass data to the view and how to expose your middle tier to the controllers. The controller chooses which view to display based on the requested URL and pertinent data. Each request is resolved by invoking a method on a controller class.

 

-          No postbacks are ever required to service a user request.

-          No viewstate is ever required to persist the state of the page.

-          No arrays of black-box server controls exist to produce the HTML for the browser.

 

-          The HTML served to the browser is generated by a separate, and Replaceable, Engine.

-          There's No Dependency on ASPX physical server files. ASPX files may still be part of your project, but they now serve as plain HTML templates, along with their code-behind classes.

 

-          The runtime environment is largely the same as in ASP.NET Web Forms, but the Request Cycle is simpler and more direct.

-          An essential part of the Web Forms model, the Page Lifecycle, Is No Longer necessary in ASP.NET MVC

 

 

 

 

The Right Perspective

 

-          As an architect or developer, it is essential that you understand the structural differences between the frameworks so that you can make a thoughtful decision. All in all, ASP.NET Web Forms and ASP.NET MVC are Functionally Equivalent in the sense that a skilled team can successfully use either to build any Web solution.

 

-          Microsoft has not positioned ASP.NET MVC as a replacement for ASP.NET Web Forms.

-          Web Forms is definitely a pattern that works for Web applications. At the same time, Ruby-on-Rails has proved that MVC can also be a successful pattern for Web applications; and ASP.NET MVC confirms this.

 

-          Web Forms embraces the RAD philosophy whereas ASP.NET MVC is TDD-oriented.

-          Further, Web Forms goes toward an abstraction of the Web that simulates a stateful environment, while ASP.NET MVC leverages the natural statelessness of the Web and guides you towards building applications that are Loosely Coupled and Inherently Testable, Search-Engine Friendly, and with Full Control Of Html.

 

 

At the End of the Day

 

-          We have seen that there are pros and cons in both Web Forms and ASP.NET MVC. Many developers, however, seem to favor ASP.NET MVC because it represents the only way to get SoC and testability into their applications. Is it really the only way? No.

-          However, ASP.NET MVC makes it easier and natural to achieve SoC and write more testable code.

-          ASP.NET MVC doesn't magically transform every developer into an expert architect and doesn't prevent developers from writing bloated and poorly designed code.

 

At the end of the day, both Web Forms and ASP.NET MVC help to build applications that are designed and implemented to deal effectively with the complexity of real-world solutions. No software magic exists, and none is yet supported by the ASP.NET platform.

 

Hope this helps.

 

Thanks & Regards,

Arun Manglick || Senior Tech Lead

 

 

Wednesday, July 15, 2009

Increase in Green IT budgets in next 12 months

BANGALORE Corporate pressure to go green and desire to strengthen an organizational environmental standing was driving Indian enterprises to explore green options-- with 90 percent IT executives expecting an increase in 'green' IT budgets over the next 12 months.

Nearly 24 per cent expect an increase of more than 10 per cent in their green IT budgets, according to the Indian findings of the Green IT report released by Symantec Corp.
Close to 60 percent respondents from large enterprises from India state they are at least discussing or are in trial stages of green IT strategy, while 39 percent are already in the process of 'implementing green.'

IT decision makers are increasingly justifying green IT solutions by more than cost and IT efficiency benefits (83) percent). Reducing cooling costs (91 percent) and corporate pressure to be green (86 percent) scored higher as reasons behind these enterprises shifting to greener options.

Furthermore, 70 percent of the respondents are now responsible or cross-charged for the electricity consumed in data centre-bringing visibility and accountability to bear on the ultimate consumer of these resources.

As CIOs take a serious relook at their strategies, green initiatives figure high on the `must do' list to perk their data centers from technology, business and environment point of view, according to Anand Naik, Director System Engineering, Symantec India.

 

Reference: Link

 

Thanks & Regards,

Arun Manglick || Senior Tech Lead

 

 

Sunday, July 12, 2009

The Oil Painting Studio

Dear Sir and madam
Allow me to introduce ourselves: We are the Oil Painting Studio.
We would like to offer our painting and giclee prints services to you.
In our studio we have 30 highly skilled professional artists with over 12 years of
experience creating paintings for our international clientele. We have worked
creatively worldwide with a large number of commercial enterprises, professional artists and galleries in Europe
and America. They all praise our professional high quality of production and artistic
workmanship. Many of our clients use our works for their business and art displays...
We safely and professionally pack and ship your paintings through FedEx or
DHL. Please send us an email today describing what is your desired topic to be painted, and some indication of
the approximate size. In return we will send you a pricelist. The Shipping cost is
based on your location and the size and dimensions of the painting or paintings required.
I hope that we will have a chance to cooperation and be good friends!
We are Looking forward to hearing from you.

Best Regards
The Oil Painting Studio


 

Sunday, July 5, 2009

How to protect your PEN drive from VIRUS

Hi!

 

How to prevent your PEN drive from VIRUS

 
Friends many of your PC/laptop's normally gets virus because of Pen Drives or USB devices (Even PC's who are not connected to network). Some Virus like Ravmon Virus , Heap41a worm which are not detected by anti virus normally spreads mostly by the Pen Drives . In such a case what can you do to prevent your PC from getting infected with Virus that spreads through USB devices or Pen Drives?

You can protect your PC by just following the simple steps below. It won't take much time.

 

  • Connect your Pen Drive or USB drive to your computer.
  • Now a dialogue window wills popup asking you to choose among the options as shown in the figure.     Don't choose any of them , Just simply click Cancel.      

 

      

 

 

  •  *Now go to Start--> Run and type cmd to open the Command Prompt window.                                 
  •  *Now go to My Computer and Check the Drive letter of your USB drive or Pen Drive. (E.g. If it is written Kingston (I:) , then I: will be the drive letter .)                                                 
  •  *In the Command Window (cmd ) , type the drive letter: and Hit Enter .                                                                                                                       
  • *Now type dir/w/o/a/p and Hit Enter 
  • *You will get a list of files. In the list , search if anyone of the following do exist  
  • 1.        Autorun.inf                                                                                                                   
  •  2.        New Folder.exe                                                                                                               
  •  3.        Bha.vbs                                                                                                                        
  •  4.        Iexplore.vbs                                                                                                                                
  •  5.        Info.exe                                                                                                                                             
  •  6.        New_Folder.exe                                                                                                                         
  •  7.        Ravmon.exe                                                                                                                                   
  •  8.        RVHost.exe or any other files with .exe Extension.  
  •  
  • If you find any one of the files above, Run the command attrib -h -r -s -a *.* and Hit Enter.
  • Now Delete each File using the following Command del filename ( E.g del autorun.inf ) .
  • That's it . Now just scan your USB drive with the anti virus you have to ensure that you made your Pen Drive free of Virus.

 

 

Hi Frnds...
This virus is very very common now...
To know whether ur system is infected just type C:\heap41a in the address bar...
if there is a folder named heap41a, then  ur system is infected...
(AVAST antivirus is the best solution for this worm...) symantec also works.