Community Tech day on Visual Studio 2010 and Asp.net 4.0 on 11 July

We are having community Tech day’s event in Kolkata on 11th of July 2010. Event will be held in Moksh Banquet Hall, Block-A, 22 Camac Street, Kolkata 700016.

Click here to Register for this CTD

Some of the key topics of discussion in the event and the speakers are given below.

Continued...

All the posts in LINQ series

In Last few weeks I have done a few LINQ series Post. Here is a list of all the posts done.


Filtering data in LINQ with the help of where clause

Using Take and skip keyword to filter records in LINQ

Continued...

Applying aggregate function in LINQ

LINQ also provides with itself important aggregate function. Aggregate function are function that are applied over a sequence like and return only one value like Average, count, sum, Maximum etc…
Below are some of the Aggregate functions provided with LINQ and example of their implementation.

Count

    int[] primeFactorsOf300 = { 2, 2, 3, 5, 5 };

    int uniqueFactors = primeFactorsOf300.Distinct().Count();

The below example provided count for only odd number.

Continued...

LINQ and various types of joins

While working with data most of the time we have to work with relation between different lists of data. Many a times we want to fetch data from both the list at once. This requires us to make different kind of joins between the lists of data.

LINQ support different kinds of join

Inner Join

    List<Customer> customers = GetCustomerList();

    List<Supplier> suppliers = GetSupplierList();

 

Continued...

Feature rich release of Visual Studio 2010

Visual studio 2010 has been released to RTM a few days back. This release of Visual studio 2010 comes with a big number of improvements on many fronts. In this post I will try and point out some of the major improvements in Visual Studio 2010.

1)      Visual studio IDE Improvement. Visual studio IDE has been rewritten in WPF. The look and feel of the studio has been improved for improved readability. Start page has been redesigned and template so that anyone can change the start page as they wish.

Continued...

Performance tuning measurement with the help of the StopWatch class

Many of the times while doing the performance tuning of some, class, webpage, component, control etc. we first measure the current time taken in the execution of that code. This helps in understanding the location in code which is actually causing the performance issue and also help in measuring the amount of improvement by making the changes.

This measurement is very important as it helps us understand the problem in code, Helps us to write better code next time (as we have already learnt what kind of improvement can be made with different code) .

Continued...

LINQ and the use of Repeat and Range operator

LINQ is also very useful when it comes to generation of range or repetition of data.  We can generate a range of data with the help of the range method.

    var numbers =

        from n in Enumerable.Range(100, 50)

        select new {Number = n, OddEven = n % 2 == 1 ? "odd" : "even"};

Continued...

LINQ and Element operators to retrieve specific records

While working with data it’s not always required that we fetch all the records. Many a times we only need to fetch the first record, or some records in some index, in the record set. With LINQ we can get the desired record very easily with the help of the provided element operators.

Simple get the first record.

If you want only the first record in record set we can use the first method [Note that this can also be done easily done with the help of the take method by providing the value as one].

    List<Product> products = GetProductList();

Continued...

Using conversion operators in LINQ to convert result set to desired format

LINQ has a habit of returning things as IEnumerable. But we have all been working with so many other format of lists like array ilist, dictionary etc that most of the time after having the result set we want to get them converted to one of our known format. For this reason LINQ has come up with helper method which can convert the result set in the desired format. Below is an example

var sortedDoubles =

        from d in doubles

        orderby d descending

Continued...

Performing Set operation Distinct, Union, Intersect and Except in LINQ

There are many set operation that are required to be performed while working with any kind of data. This can be done very easily with the help of LINQ methods available for this functionality. Below are some of the examples of the set operation with LINQ.

Finding distinct values in the set of data.

We can use the distinct method to find out distinct values in a given list.

    int[] factorsOf300 = { 2, 2, 3, 5, 5 };

Continued...

LINQ And Group keyword for grouping of data

While working with any kind of advanced query grouping is a very important factor. Grouping helps in executing special function like sum, max average etc to be performed on certain groups of data inside the date result set. Grouping is done with the help of the Group method. Below is an example of the basic group functionality.

    int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

   

    var numberGroups =

Continued...

Using the Order clause to sort the result set

After filtering and retrieving the records most of the time (if not always) we have to sort the record in certain order. The sort order is very important for displaying records or major calculations. In LINQ for sorting data the order keyword is used.

With the help of the order keyword we can decide on the ordering of the result set that is retrieved after the query.  Below is an simple example of the order keyword in LINQ.

    string[] words = { "cherry", "apple", "blueberry" };

    var sortedWords =

Continued...

LINQ Using TakeWhile and SkipWhile to filter records based on condition

In my last post I talked about how to use the take and the Skip keyword to filter out the number of records that we are fetching. But there is only problem with the take and skip statement. The problem lies in the dependency where by the number of records to be fetched has to be passed to it. Many a times the number of records to be fetched is also based on the query itself.

For example if we want to continue fetching records till a certain condition is met on the record set. Let’s say we want to fetch records from the array of number till we get 7. For this kind of query LINQ has exposed the TakeWhile Method.

    int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

Continued...

Filtering records with the Skip and take keyword in LINQ

In LINQ we can use the take keyword to filter out the number of records that we want to retrieve from the query. Let’s say we want to retrieve only the first 5 records for the list or array then we can use the following query

    int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

    var first3Numbers = numbers.Take(3);

The TAKE keyword can also be easily applied to list of object in the following way.

Continued...

LINQ and where clause to filter out data

LINQ has bought with itself a super power of querying Objects, Database, XML, SharePoint and nearly any other data structure. The power of LINQ lies in the fact that it is managed code that lets you write SQL type code to fetch data. 

Whenever working with data we always need a way to filter out the data based on different condition. In this post we will look at some of the different ways in which we can filter data in LINQ with the help of where clause.

Simple Filter for an array.

Let’s say we have an array of number and we want to filter out data based on some condition. Below is an example

Continued...

Code expression HTML encode in Asp.Net

Hi,


One of the new features in Asp.Net 4.0 is the inclusion of Code expressions which are HTML encoded by default. IN Asp.Net the code expression by default does not encode any text and hence it can leave the chance of Cross Site scripting attack.


In Asp.Net 4.0 we can now write expression which will get encoded by itself. For writing HTML encoded expression we need to use the following expression

 

Continued...

Request Validation now validates All Asp.Net resources

Hi,

When a page is submitted, users can also script along with the post data. Also unauthorized postback could be triggered. The event validation mechanism reduces the risk of unauthorized postback requests and callbacks when the EnableEventValidation property is set to true. This would help and provide default level of protection against cross site scripting.

 

In the previous versions of Asp.Net request validation was turned on by default but the validation would only apply to the asp.net pages (aspx pages and their code behind). This means there is no validation for other files requested like css, image etc.

 

Continued...

Single Quotation Marks will be encoded in HtmlEncode and UrlEncode

Hi,

One of the small but important change in the Asp.Net 4.0 is the change is the Encode methods. Now the HtmlEncode and UrlEncode methods in the HttpUtility and HttpServerUtility class respectively also encode the single quote (‘).

The HtmlEncode method encodes instances of the single quotation mark as "&#39;".

The UrlEncode method encodes instances of the single quotation mark as "%27".

Vikram


"Have Breakfast… or…Be Breakfast!"

Who sells the largest number of cameras in India?

Your guess is likely to be Sony, Canon or Nikon. The answer is: None of the above. The winner is Nokia, whose main line of business in India is not cameras but cellphones.

The reason is that cameras bundled with cellphones are outselling standalone cameras. Now, what prevents the cellphone from replacing the camera outright? Nothing at all.

Try this. Who runs the biggest music business in India? The answer is Airtel. By selling caller tunes (that play for 30 seconds) Airtel earns more than music companies do by selling albums.

Airtel is not in the music business. It is the mobile service provider with the largest subscriber base in India. That sort of a competitor is difficult to detect and even more difficult to beat. By the time you have identified him, he has already gone past you. But if you imagine that Nokia and Bharti (Airtel's parent) are breathing easy, you couldn't be further from the truth.

Continued...

Release candidate for Visual Studio 2010 Released

Hi,

Today Microsoft has released Visual Studio 2010 (VS 2010) RC for MSDN Subscriber. It will be available for the General people on RC on 10th February.

If you are an MSDN subscriber you can go ahead and download the bits right now from the link below.

http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx

The early feedback on Twitter seems very good already about the performance. Do check it out.

 

Continued...

Displaying Multi line wrapped text in web form

Hi,


Many a times there is requirements for us to display text in multi-line in web pages. The first try that most of the people do is by giving a fixed width to the label. But this never works.

Height and Width works only for block level element. Label is an inline element and hence setting width does not work.

 

What you can instead do is use a textbox with CSS that will make it looks like a label. To do this we need to set the following properties.

Continued...

Comparing different type with Double Equal operator and Equal method

Hi,

 

There are normally two ways to compare 2 objects. One by using == operator and by using the equals method. But these two are not same in the way they implements the comparison.

 

The difference is there in the type of object (reference type or value type)

 

Value Type

Continued...

Using Observer design pattern to notify multiple class on change

Hi,


Many times when programming we come across situation where by change in one change needs to be updated in multiple object. For example if a parameter is used to make multiple calculation in different objects then on change of that parameter all the objects need to be notified of the change.  Or for example when the windows (operating system) or Dot Net framework shut downs or closes then it notifies all the application running on it to close so that it can make a clean close.

 

Continued...

Received the Microsoft Most Valuable Professional award for the year 2010

Hi,

 

I feel great joy to share with all that I have been rewarded the Microsoft MVP award for the year 2010 also. It feels great to have received the Award 2 year in succession.

 

A very Big Thanks to the MVP Team, My MVP lead and the Microsoft for giving the MVP award to me.

Thanks to all the friends, developers, and community members that have worked with me. I will try and continue my work forward in 2010......

Vikram


Microsoft has announced the launch of Visual Studio 2010 Beta 2 with a Go Live License and tons of improvement

Hi,

Microsoft has announced the release of the Beta 2 of the Visual Studio 2010. MSDN Subscribers can download the same today and this will be available for the general Public of Wednesday. The link for download is

http://msdn.microsoft.com/hi-in/vstudio/dd582936(en-us).aspx

VS 2010 and .NET 4 bring a huge number of improvements and additions. They include big advances for ASP.NET web development, WPF and Windows Forms client development, SharePoint development, Silverlight development, data development, parallel computing development, and cloud computing development. VS 2010 also delivers a ton of improvements in the core IDE, code editors, programming languages, and enterprise design, architect, and testing tools. 

Continued...

Join the full day free community techdays event on 11th October 2009 in Kolkata

Hi,

Although a little late in blogging this, But I would like to invite all people in and around kolkata to join the KolkataNET - KolkataITPro - Community Tech Day on 11th Oct. 2009. The event is being held at International School of Business & Media, Kolkata Campus situated at Kolkata (address below). The event does not require any registeration free and is free.

The agenda for the event are below.

Continued...

An easy way to install application for web development Web Platform Installer 2.0

Hi,

Of late Microsoft Has been doing great job in creating an great experience for installation for both development component for Asp.net and IIS server and also available free open source software. Yes I am talking about the Web Platform Installer 2.0.

The web Platform Installer has been a great success, and is very user friendly tool to install most of the available software required for web development along with many available open source platforms and application.

Web Platform Installer 2.0 (Also known as Web PI) was released recently and can be downloaded from the link below.

http://www.microsoft.com/web/downloads/platform.aspx

Continued...

Having clause and Grouping Based on condition in LINQ

Hi,

While querying with LINQ, some times we will have to use the group By clause. But many a times we also want to use the having clause of SQL with the group by clause in the LINQ. There is no direct having keyword in LINQ to do this we need to use the where clause itself.

You can query the LINQ to SQL to have both Group By and Having like this.

Continued...

LINQ queries and IN clause in SQL

Hi,

When working with the LINQ queries for SQL one of the common queries that we need to run is the select query with IN clause. In SQL IN clause is used to provide more than one value to match in the where clause.

Something like the query below

Select * from Table
where column1 in (‘Value1’, ‘Value2’, ‘Value3’)

To do a similar query in LINQ we can use

var list = from t in table
                where t.column1 = Value1’
                And t.column1 = Value2’
                t.column1 = Value3’
                Select t

Continued...

A workshop for IT Professionals on 15th September on Implementing SECURITY INSIDE-OUT with MICROSOFT Technologies
Hi,

There an interactive live session on September 15, 2009 on how the New Efficiency Products will help you manage security in a simpler way. This session will occur across 16 cities at NIIT centers as a live session with benefit of face-to-face teaching, each participant having their own computers to work on, and having the ability to ask questions any time. The following event is available for the following city.

Ahmedabad       
Lucknow
Bangalore          
Mumbai
Bhopal 
Mysore
Bhubhaneswar  
Nagpur
Chandigarh        
Nasik
Chennai              
New

Continued...
 
Copyright © 2006 - 2010 Vikram Lakhotia