Ramani Sandeep's Blog

DotNetting – Fast , Easy Way of Developing Applications

Archive for the ‘C# 3.0’ Category

What is new in ASP.NET 3.5 & 4.0 ?

Posted by Ramani Sandeep on January 5, 2010

New Features in ASP.NET 3.5

The .NET Framework version 3.5 includes enhancements for ASP.NET in the following areas:

  • A new EntityDataSource control that exposes the Entity Data Model through the ASP.NET data source control architecture.
  • A new ListView data control that displays data and that provides a highly customizable UI.
  • A new LinqDataSource control that exposes Language-Integrated Query (LINQ) through the ASP.NET data source control architecture.
  • A new merge tool (Aspnet_merge.exe) that merges precompiled assemblies to support flexible deployment and release management. This feature is not available in Visual Web Developer Express Edition.

ListView Data Control

The ListView control combines many aspects of existing data controls. The ListView control is useful for displaying data in any repeating structure, similar to the DataList and Repeater controls. Unlike those controls, the ListView control supports edit, insert, and delete operations as well as sorting and paging. The paging functionality is provided for ListView by the new DataPager control.

The ListView control is a highly customizable control that enables you to use templates and styles to define the control’s UI. Like the Repeater, DataList, and FormView controls, templates in the ListView control are not predefined to render specific UI in the browser.

DataPager Control

The DataPager control is used to page through data that is displayed by a control that implements the IPageableItemContainer interface, such as the ListView control. The DataPager control supports built-in paging UI. You can specify the paging UI by using the NumericPagerField object, which lets users select a page by page number. You can also use the NextPreviousPagerField object, which lets users navigate through pages one page at a time, or to jump to the first or last page. Alternatively, you can create custom paging UI by using the TemplatePagerField object.

LinqDataSource Control

The LinqDataSource control exposes Language Integrated Query (LINQ) through the ASP.NET data source control architecture. You use the LinqDataSource control when you are creating a Web page that retrieves or modifies data and you want to use the programming model that is provided by LINQ. You can simplify the code in a Web page by enabling the LinqDataSource control to automatically create the commands for interacting with the data. By using the LinqDataSource control, you can reduce the amount of code that you must write to perform data operations when compared to performing the same operations in the SqlDataSource control or the ObjectDataSource control. When you use the LinqDataSource control, you also benefit by learning only one programming model to interact with different types of data sources.

You can use declarative markup to create a LinqDataSource control that connects to data from either a database or a data collection such as a collection. In the markup, you can specify the criteria for displaying, filtering, ordering, and grouping data. When the data source is an SQL database table, you can also configure a LinqDataSource control to update, insert, and delete data. You do not have to write the SQL commands to perform these tasks. The LinqDataSource class provides an event model that enables you to customize display and update behavior.

ASP.NET Merge Tool

The ASP.NET merge tool (Aspnet_merge.exe) lets you combine and manage assemblies that are created by the ASP.NET pre-compilation tool (Aspnet_compiler.exe). (The merge tool was released earlier as an add-on for Visual Studio 2005,) The merge tool creates single assemblies for the site. You can create an assembly for the whole Web site, for each Web site folder, or for just the files that make up the Web site UI (pages and controls).

Read more

New features introduced in ASP.NET 4.0 & Visual Studio 2010

  • Code Snippets
  • New Profiles
  • Generate From Usage
  • Multi-Targeting
  • MultiMonitor
  • Code Navigation in Class Files
    • Code Navigation
    • View Call Hierarchy
    • Code Identifier Highlighting
  • Intellisense Improvements
  • EnablePersistedSelection
  • Web.Config Transformation
  • URL Routing
  • Add Reference Dialog
  • Compressing Session Values
  • Improvements in C# 4.0
    • Dynamic lookup
    • Named parameters
    • Optional parameters
  • Meta Tags
  • Generating Client IDs
  • Permanent Redirect
  • New Browser Definitions
  • Publishing a Project
    • Package/Publish
    • Deploy SQL
    • Silverlight Applications

Read more

Shout itkick it on DotNetKicks.com

Posted in ASP.NET 3.5, ASP.NET 4.0, C# 3.0 | Tagged: , , | 1 Comment »

Lazy Loading

Posted by Ramani Sandeep on December 11, 2009

Introduction

Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program’s operation if properly and appropriately used. The opposite of lazy loading is Eager Loading.

Article – 1: jQuery Tabs and Lazy Loading by Malcolm Sheridan

In this article I will connect to the Northwind database using LINQ to SQL, and display customer and product information in separate tabs. I’ll also show you one way of lazy loading these tabs so the data is retrieved only once, not each time a tab is selected.

Read more

Article – 2: Lazy Loading jQuery Tabs with ASP.NET by Mikesdotnetting

This article looks at efficient use of jQuery tabs when displaying data. Specifically, it covers how to lazy-load data, so that it is only accessed and displayed if the tab is clicked.

Lazy Loading is a well-known design pattern that is intended to prevent redundant processing within your application. In the case of tabbed data, there seems little point retrieving and binding data that appears in a tabbed area that no one looks at. So, this examples covers how to defer data access and display until the user wants it – which is defined by them clicking the relevant tab.

Read more

Article – 3: Eager Loading and Lazy Loading in ADO.NET Data Services by Gil Fink

The default behavior of a data service’s .NET client is not to load the entities’ associated objects. When we request an entity we will get it from the service but its associated objects will not load up at all.

Lets say that I have two entities in my program

  • a course
  • a department

The associations between the entities are that a department can have a lot of courses and a course belongs to one department.

When I load a department it’s list of courses will be empty. trying to iterate the list of courses will give nothing because the courses will not load until we tell them to be loaded explicitly.

This is done by the LoadProperty method of the data service context.

Read more

 

I have a great learning experience thru this.

Now its your turn to have it.

kick it on DotNetKicks.com
Shout it

Posted in ASP.NET, ASP.NET 3.5, ASP.NET Ajax, C# 3.0, JQuery, Linq | Tagged: , , , , , , , | Leave a Comment »

.NET Challenge – for or foreach?

Posted by Ramani Sandeep on November 2, 2009

Question:

for should be used instead of foreach to iterate over collections in performance-critical loops.

Answer: True

foreach uses an enumerator which can sometimes be slower than the simple iteration of a variable in a for loop. Enumerators, such as those contained in the .NET Framework, have both managed heap and virtual function overhead. The amount of overhead depends on the collection used and the version of the .NET Framework. As always, the best way to determine the overhead between techniques is to run a performance test and compare.

To illustrate the performance impact, 10 strings were concatenated 100 times using the techniques outlined below. 

Running against .NET Framework 3.5 using an ArrayList, a generic List and a LinkedList with 5,000 strings, the following results were obtained using Ants Performance Profiler 5:

Wall Clock Time (ms) Loop Structure (5,000 strings)
25.003 for LinkedList<string>
0.037 foreach LinkedList<string>
0.039 for ArrayList
0.053 foreach ArrayList
0.019 for List<string>
0.034 foreach List<string>

 

Except for the LinkedList, the for loop is faster.

The for loop is thought by many developers to be less readable and maintainable than foreach. Using foreach also makes it possible to iterate across anything that’s IEnumerable, allowing for the creation of more general algorithms and the use of "yield" to build custom collections.

It is normally good practice to code for clarity rather than micro-optimization.

Reference : Rad-gate

Posted in ASP.NET, ASP.NET 3.5, C# 2.0, C# 3.0 | Tagged: , , , , | Leave a Comment »

Watch the Video of Luke Hoban & Luca Bolognese

Posted by Ramani Sandeep on October 14, 2009

Linq to SQL by Luca Bolognese

Luca Bolognese is the Principal Program Manager Lead on the C# team. His talk on LINQ to SQL endows developers with the knowledge necessary to wield the tools that drive data driven application development under C# 3.0. A consummate speaker, Luca skillfully guides his audience through the elements that comprise LINQ to SQL development.

watch the video here

An In-Depth Look at C# 3.0 by Luke Hoban

Luke Hoban was the PM who drove the development of LINQ to Objects, and the man who created the now famous implementation of a ray tracer in a single, very long, LINQ query expression. He is now focusing his efforts on F#. By listening to his talk on C# 3.0 features you will get a chance to see a detailed and specific analysis of how LINQ works. Listening to him give this talk marked a turning point in my understanding of LINQ. For the first time I understood how the team folded extension methods and query expressions together to create the marvelously supple and deceptively simple syntax that we know as LINQ.

watch the video here

Posted in ASP.NET 3.5, C# 3.0 | Tagged: , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 37 other followers