Wednesday, July 25, 2012

Advantages and Disadvantages of Entity Framework in .NET

The EF is essentially an O/R mapping tool. It takes care of object persistence for you. In other words, it acts as your data layer. writing applications using entity framework saves lot of development time and its good..if we are developing enterprise applications, we need to think about performance..all in all its good for small applications..

  1. Advantages : One common syntax ( LINQ / Yoda ) for all object queries whether it is database or not , Pretty fast if used as intended , easy to implement SoC , less coding required to accomplish complex tasks
    Disadvantages : you have to think in a non traditional way of handling data , not available for every database
  2. Disadvantage: If there is any schema change in database FE won’t work!!! You have to update the schema in solution as well!!!
    Advantage: Its fast and straight forward using LINQ/FE objects For Add/Modify/Delete/Update.
  3. Advantages:-Easy to map business objects (with drag & drop tables on environment).
    -It keeps a good performance when you work with a small / middle domain model.
    Disadvantages:-It's limited when you work with a huge domain model.
    -Scalability.

Thursday, April 19, 2012

Web Performance Best Practices and Rules By Yahoo DEVELOPER Team

Yahoo!'s Exceptional Performance team has identified 34 rules that affect web page performance. YSlow's web page analysis is based on the 23 of these 34 rules that are testable. Click each performance rule below to see the details.
  1. Minimize HTTP Requests
  2. Use a Content Delivery Network
  3. Avoid empty src or href
  4. Add an Expires or a Cache-Control Header
  5. Gzip Components
  6. Put StyleSheets at the Top

Object cannot be cast from DBNull to other types. How to resolve this Exception Message?

Error Message: Object cannot be cast from DBNull to other types.

Solution: This exception occurred because the data type of data column of data row accepts null values, but the data type in C# not. All the data type that are "value types" (struct) don´t accepts null values.

Wednesday, April 18, 2012

Maximum SharePoint Content DB Capacity

100GB is not the limit, its actually a best practise. This post lists out few suggestions. The following represents Microsoft's guidance and best practices on content databases, as specified in various places on technet.microsoft.com:

  1. Limit the content database size to 100GB; use multiple content databases if necessary.
  2. Create multiple data files and spread them across multiple disks; only create files in the primary file group.
  3. The number of data files should be less than or equal to the number of core CPUs; count dual core processors as two CPUs; count each processor that supports hyper-threading as one CPU.

Tuesday, April 17, 2012

JQuery Autocomplete Key/Value

This solution with key/value with cascading Auto complete with web service.

This JQuery Script

<script type="text/javascript"> 
    $(document).ready(function () { 
      $("[id$='txRequesterName']").attr('disabled', true); 
      $("[id$='txAssetName']").attr('disabled', true); 
      $("[id$='txCompanyName']").autocomplete({ 
        source: function (request, response) { 
          $.ajax({ 
            type: "POST", 
            url: "WebService.asmx/GetCompany", 
            dataType: "json", 
            data: "{\"companyName\":\"" + request.term + "\"}", 
            contentType: "application/json; charset=utf-8", 
            success: function (data) { 
              response($.map(eval(data.d), function (item) { 
                return { 
                  label: item.label, 
                  value: item.label, 
                  id: item.value 
                } 
              })); 
            } 
          }) 
        }, 
        minLength: 1, 
        select: function (event, ui) { 
          $("[id$='txCompanyID']").val(ui.item.id); 
          $("[id$='txRequesterName']").attr('disabled', false); 
        }, 
        change: function (event, ui) { 
          $("[id$='txRequesterName']").val(''); 
          $("[id$='txRequesterName']").attr('disabled', false); 
        } 
      }); 

Sunday, April 15, 2012

Differences between value type and reference type?


Value Type Reference Type
Value type variable directly contain value itself. Reference type variable contain the address of object where the values are placed in memory. Or we can say they store the reference to object.
All value types are implicitly derived from System.ValueType. They are derived from System.Object class.
They doesn’t support inheritance. Means they are sealed implicitly. They can be inherited. They are internal by default.
A value type variable can’t be assigned value null. An object can have value null.
They can be declared without new operator. They can’t be declared without new operator.

Differentiate between Structure and Class in .net?

                        Structure

                           Class

Structures are value type, i.e. variable of struct type directly contain the data of structure

Classes are reference type, i.e variable of class (known as object) contain the reference to data.

Do not require, urgently, new operator to do its instantiation. Or instantiation can be done without new operator.

Do require new operator to do instantiation.

Each variable will have its own set of data even if they have same values.

More than one object can have reference to same data.

Default Value of a struct type can’t be null.

Default value of an Object of a class type is null.

Friday, April 13, 2012

What is the difference between HTTP-Post and HTTP-Get?

There are two common ways to pass data from one page to another, using http Get and Post methods. In Get method, data passed to server using URL encoding. So with Get method data added in URL as query string.

As their names imply, both HTTP GET and HTTP POST use HTTP as their underlying protocol. Both of these methods encode request parameters as name/value pairs in the HTTP request.
The GET method creates a query string and appends it to the script's URL on the server that handles the request.
The POST method creates a name/value pairs that are passed in the body of the HTTP request message.

What is Globalization? What are the steps to follow to get user's culture at run time?

What is Globalization?
Globalization is the process of creating an application that meets the needs of users from multiple cultures. This process involves translating the user interface elements of an application into multiple languages, using the correct currency, date and time format, calendar, writing direction, sorting rules, and other issues. Accommodating these cultural differences in an application is called localization.
The Microsoft .NET Framework simplifies localization tasks substantially by making its formatting, date/time, sorting, and other classes culturally aware. Using classes from the System.Globalization namespace, you can set the application’s current culture, and much of the work is done automatically!

What are the 3 different ways to globalize web applications?

Detect and redirect approach : In this approach we create a separate Web application for each supported culture, and then detect the user’s culture and redirect the request to the appropriate application. This approach is best for applications with lots of text content that requires translation and few executable components.
Run-time adjustment approach : In this approach we create a single Web application that detects the user’s culture and adjusts output at run time using format specifiers and other tools. This approach is best for simple applications that present limited amounts of content.
Satellite assemblies approach : In this approach we create a single Web application that stores culture-dependent strings in resource files that are compiled into satellite assemblies. At run time, detect the user’s culture and load strings from the appropriate assembly. This approach is best for applications that generate content at run time or that have large executable components.

Thursday, April 12, 2012

What are Cascading style sheets? What is the use of Style Builder?

What are the 2 ways provided by ASP.NET to format output in a Web application?
1. Use cascading style sheets (CSS) to control the appearance of elements on a Web form.These styles can set the color, size, font, and behavior of the HTML elements on a Web page.
2. Use Extensible Stylesheet Language Transformations (XSLT) to convert information from an Extensible Markup Language (XML) file to HTML output and position that information on a Web form. XSLT puts data from the XML file into HTML elements and applies styles to those elements.

What are Cascading style sheets?

Cascading style sheets (CSS) collect and organize all of the formatting information applied to HTML elements on a Web form. Because they keep this information in a single location, style sheets make it easy to adjust the appearance of Web applications.

Tuesday, April 10, 2012

What is ViewState? What are the performance implications of ViewState?

What is ViewState?
Web forms have very short lifetimes.In ASP.NET, the data that is entered in controls is encoded and stored in a hidden field. This encoded data is then sent with each request and restored to controls in Page_Init. The data in these controls is then available in the Page_Load event.The data that ASP.NET preserves between requests is called the Web form’s view state.

How do you enable or disable a ViewState for a control on the page?

Every ASP.NET control has a property called EnableViewState. If EnableViewState is set to true ViewState is enabled for the control. If EnableViewState is set to false ViewState is disabled for the control.

How do you enable or disable a ViewState at the page level?

At the page level you can enable or disable ViewState using EnableViewState property of the page.

Monday, April 9, 2012

What are ASP.NET Validation controls? What is a validation group?

What are ASP.NET Validation controls?
ASP.NET provides validation controls to help you check Web form data entries before the data is accepted and saved in the Database. Validation controls can be used to address the following questions.
1. Did the user enter anything?
2. Is the entry the appropriate kind of data (For example, Date of Birth should be a valid Date, Name should be a string etc.)?
3. Is the data within a required range?(For example age cannot be greater than 100 years)
The validation controls check the validity of data entered in associated server controls on the client before the page is posted back to the server.Most validity problems can be caught and corrected by the user without a round-trip to the server.

Where do the ASP.NET validation controls validate data, on the Client or on the Web Server?

ASP.NET validation controls validate data first on the client and then on the web server. If a client disables javascript on the browser then, client side validations are bypassed and validations are performed on the web server.

What are the steps involved in using a transaction object in ADO.NET?

What are the steps involved in using a transaction object in ADO.NET?
1.Open a database connection.
2.Create the transaction object using the database connection object’s BeginTransaction method.
3.Create command objects to track with this transaction, assigning the Transaction property of each command object to the name of the transaction object created in step 2.
4.Execute the commands. Because the purpose of transaction processing is to detect and correct errors before data is written to the database, this is usually done as part of an error-handling structure.
5.Commit the changes to the database or restore the database state, depending on the success of the commands.
Close the database connection.

Sunday, April 8, 2012

What is a transaction? How DataSets provide transaction processing?

What is a transaction?
Answer: A transaction is a group of commands that change the data stored in a database. The transaction, which is treated as a single unit, assures that the commands are handled in an all-or-nothing fashion. if one of the commands fails, all of the commands fail, and any data that was written to the database by the commands is backed out. In this way, transactions maintain the integrity of data in a database. ADO.NET lets you group database operations into transactions.

What is the main purpose of database transactions?
Answer: The main purpose of database transactions is to maintain the integrity of data in a database.

What is Tracing and what are the advantages of using tracing to log exceptions?

What is Tracing and what are the advantages of using tracing to log exceptions?
Answer: Tracing is a technique for recording events, such as exceptions, in an application. There have always been ways to record errors in an application - usually by opening a file and writing error messages to it. But tracing offers the following significant advantages:
Standardization:Building tracing into the .NET Framework ensures that programming techniques are the same across all the applications you develop with the .NET Framework.
Built-in Web support:ASP.NET extends the .NET Framework tools by including information related to the performance and behavior of Web requests.
Configuration:You can turn tracing on and off using settings in your application’s configuration file. You don’t have to recompile your application to enable or disable tracing.
Performance:While disabled, tracing statements do not affect application performance.

Saturday, April 7, 2012

How do map .htm and .html files to the ASP.NET executable using the IIS snap-in?

Answer: To map .htm and .html files to the ASP.NET executable using the IIS snap-in, follow these steps:
1. In the IIS snap-in, select the folder containing your Web application, and then choose Properties from the Action menu. IIS displays the Properties dialog box.
2. Click the Home Directory or Virtual Directory tab, and then click Configuration. IIS displays the Application Configuration dialog box, as shown in the diagram below.

Friday, April 6, 2012

TIPS - Increase SQL Server stored procedure performance

a) Define / Use of variables within stored procedure

b) Use of uncommon values in parameter values on the first execution after a stored proc is created/recompiled, resulting in a bad query plan chosen by the optimizer.

c) Join order. What's an inner and outer table. What is nested join and/or merge join. And understand how the optimizer chooses the join order.

Thursday, April 5, 2012

User Defined Functions and Stored Procedures

  1. UDF are simpler to invoke than Stored Procedures from inside another SQL statement. They are Complex to Invoke.
  2. SQL functions that return non-deterministic values are not allowed to be called from inside User Defined Functions. GETDATE is an example of a non-deterministic function. Every time the function is called, a different value is returned. Therefore, GETDATE cannot be called from inside a UDF you create, but could not be used inside the function itself. Non-deterministic values are not allowed to be called from inside Stored Procedure.
  3. The User Defined Function must be prefaced with the owner name, DBO in this case. Not mandatory.

Friday, March 23, 2012

Tricky Interview Questions – SharePoint


Information Architect

This will most likely be someone working for a consultancy company who will be tasked with gathering requirements and defining the goals for the SharePoint deployment. Then following that, defining the architecture for the deployment. This will include a knowledge of areas such as capacity planning, taxonomy, security and governance.

A question to ask this person in interview to test their knowledge is:

Thursday, March 22, 2012

What is a Constructor in C#?


A constructor is a member function that has the same name as the class name and is invoked automatically when the class is instantiated. A constructor is used to provide initialization code that gets executed every time the class is instantiated.

Points to be noted on constructors:

  • Constructors cannot be "virtual".
  • They cannot be inherited.
  • Constructors are called in the order of inheritance.
  • If we don't write any constructor for a class, C# provides an implicit default constructor, i.e., a constructor with no argument.
  • Constructors cannot return any value.
  • Constructors can be overloaded.

The syntax for a constructor is as follows:

[modifier] name (parameters)
{
  // constructor body
}

Wednesday, March 21, 2012

Inheritance & Polymorphism

When you derive a class from a base class, the derived class will inherit all members of the base class except constructors, though whether the derived class would be able to access those members would depend upon the accessibility of those members in the base class. C# gives us polymorphism through inheritance. Inheritance-based polymorphism allows us to define methods in a base class and override them with derived class implementations. Thus if you have a base class object that might be holding one of several derived class objects, polymorphism when properly used allows you to call a method that will work differently according to the type of derived class the object belongs to.

Difference between WCF vs. Web Services (ASMX)

Categories WCF ASMX (Web Services)
Protocols Support
  1. HTTP
  2. TCP
  3. Name Pipes
  4. MSMQ
  5. Custom
  6. UDP
  1. HTTP
Hosting
  1. A WCF component can be hosted in any kind of environment in .NET 3.0, such as a console application, Windows application, or IIS.
  2. WCF services are known as 'services' as opposed to web services because you can host services without a web server.
  3. Self-hosting the services gives you the flexibility to use transports other than HTTP.
Can be hosted only with HttpRuntime on IIS

Tuesday, March 20, 2012

Garbage collection in .NET


.Net is the much hyped revolutionary technology gifted to the programmer's community by Microsoft. Many factors make it a must use for most developers. In this article we would like to discuss one of the primary advantages of .NET framework - the ease in memory and resource management.
Every program uses resources of one sort or another-memory buffers, network connections, database resources, and so on. In fact, in an object-oriented environment, every type identifies some resource available for a program's use. To use any of these resources, memory must be allocated to represent the type.

Monday, March 19, 2012

Caching

What is caching?
High-performance Web applications should be designed with caching in mind. Caching is the technique of storing frequently used items in memory so that they can be accessed more quickly. Caching is important to Web applications because each time a Web form is requested, the host server must process the Web form’s HTML and run Web form code to create a response. By caching the response, all that work is bypassed. Instead, the request is served from the reponse already stored in memory.
Caching an item incurs considerable overhead, so it’s important to choose the items to cache wisely. A Web form is a good candidate for caching if it is frequently used and does not contain data that frequently changes. By storing a Web form in memory, you are effectively freezing that form’s server-side content so that changes to that content do not appear until the cache is refreshed

Abstract class and Interface


Introduction
In this article along with the demo project I will discuss Interfaces versus Abstract classes. The concept of Abstract classes and Interfaces is a bit confusing for beginners of Object Oriented programming. Therefore, I am trying to discuss the theoretical aspects of both the concepts and compare their usage. And finally I will demonstrate how to use them with C#.

Background
An Abstract class without any implementation just looks like an Interface; however there are lot of differences than similarities between an Abstract class and an Interface. Let's explain both concepts and compare their similarities and differences.

What is an Abstract Class?
An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

 

Sunday, March 18, 2012

UML basics: An introduction to the Unified Modeling Language

A little background

As I mentioned, UML was meant to be a unifying language enabling IT professionals to model computer applications. The primary authors were Jim Rumbaugh, Ivar Jacobson, and Grady Booch, who originally had their own competing methods (OMT, OOSE, and Booch). Eventually, they joined forces and brought about an open standard. (Sound familiar? A similar phenomenon spawned J2EE, SOAP, and Linux.) One reason UML has become a standard modeling language is that it is programming-language independent. (UML modeling tools from IBM Rational are used extensively in J2EE shops as well in .NET shops.) Also, the UML notation set is a language and not a methodology. This is important, because a language, as opposed to a methodology, can easily fit into any company's way of conducting business without requiring change.

The ASP.NET Page Life Cycle

Each time a request arrives at a Web server for an ASP.NET Web page, the first thing the Web server does is hand off the request to the ASP.NET engine. The ASP.NET engine then takes the request through a pipeline composed of numerous stages, which includes verifying file access rights for the ASP.NET Web page, resurrecting the user's session state, and so on. At the end of the pipeline, a class corresponding to the requested ASP.NET Web page is instantiated and the ProcessRequest() method is invoked (see Figure 1).

clip_image002

Figure 1. ASP.NET Page Handling

Saturday, March 17, 2012

Programming with the SharePoint 2010 object model

In this exercise you will create a new console application that programs against the SharePoint Foundation 2010 object model to create new lists and add items to a SharePoint 2010 site. This will illustrate some on the aspects of the SharePoint Foundation 2010 object model as well as show some of the issues about which versions of assemblies to use when you do this type of programming.

1.   If you haven't already done so, you need to run the batch file named LabSetup01.bat to create the site located at http://intranet.contoso.com/sites/Lab01.

2.       Open the browser and navigate to the new site at http://intranet.contoso.com/sites/Lab01/default.aspx. You should see that this new site has been created as a blank site with no existing lists. In the following steps you are going to write a program that uses the SharePoint 2010 object model to create a few new lists in this site and to populate these lists with sample data.

Friday, March 16, 2012

Working with the SharePoint 2010 Ribbon and In-place Editing

In this exercise, you will complete work inside the top-level site of the site collection you created in the previous exercise at http://intranet.contoso.com/sites/Lab01A. You will begin by adding and viewing items inside of some of the lists that are automatically created as part of a new Team site so you can experience the new paradigm for in-place editing. After that, you will work with a Web Part Page so you can experience how the SharePoint 2010 user interface has changed the way users manage Web Parts.

1.       At this point you should be at the home page of the site created in the previous exercise at the URL http://intranet.contoso.com/sites/Lab01A/SitePages/Home.aspx. Note that the home page is not default.aspx but rather a wiki page named Home.aspx located inside a wiki page library named SitePages.

2.       Observe that the page Home.aspx already contains some generic content including large text block at the top of the page which reads "Welcome!". Go into edit mode for the wiki page by clicking the Edit Page menu within the Site Actions menu.

Thursday, March 15, 2012

.NET Remoting – Question and Answers


01. What distributed process frameworks outside .NET do you know?
Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object Model  (DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).

02. What are possible implementations of distributed applications in .NET?  .NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in  System.Runtime.Remoting and System.Web.Services.

03. When would you use .NET Remoting and when Web services?
Use remoting for more efficient exchange of information when you control both ends of the application. Use Web services for     open-protocol-based information exchange when you are just a client or a server with the other end belonging to someone else.

Wednesday, March 14, 2012

Creating a Site Collection in SharePoint Central Administration

Exercise 1: Creating a Site Collection in SharePoint Central Administration
In this exercise you will create a new SharePoint site collection using the SharePoint 2010 Central Administration site.

1.  Make sure you are logged in as the local administrator.

2. Navigate to the SharePoint 2010 Central Administration site. You can do this using the shortcut inside the Administrative Tools menu of the Windows Start menu. On this VM you can also get to the SharePoint 2010 Central Administration site by opening the browser and navigating to the following URL:
http://YourServerNameHere:2010/default.aspx

Tuesday, March 13, 2012

Building Collaborative Applications Without Code Using Office SharePoint Designer 2007


Event Overview

Learn how to use Microsoft Office SharePoint Designer 2007 to build productive and efficient solutions on Microsoft SharePoint Products and Technologies. In this webcast, we explain how you can use SharePoint Designer 2007 to create and deploy interactive Web solutions on the SharePoint platform—without writing any code. We also describe how to build reporting and tracking applications and collaborative workflows, and show you how to customize Microsoft Windows SharePoint Services application templates.

Presenter: Rob Mauceri, Principal Group Program Manager, Microsoft Corporation

Sunday, March 11, 2012

Features of the Search Component of Office SharePoint Server 2007


1.    Write the features of the search component of Office SharePoint Server 2007?

The search component of Office SharePoint Server 2007 has been significantly enhanced by this release of SharePoint Products and Technologies. New features provide:
* A consistent and familiar search experience.
* Increased relevance of search results.
* New functions to search for people and expertise.
* Ability to index and search data in line-of-business applications and
* Improved manageability and extensibility.

2.    What are the benefits of Microsoft Office SharePoint Server 2007?


* Provide a simple, familiar, and consistent user experience.
* Boost employee productivity by simplifying everyday business activities.
* Help meet regulatory requirements through comprehensive control over content.
* Effectively manage and repurpose content to gain increased business value.
* Simplify organization-wide access to both structured and unstructured information across disparate systems.
* Connect people with information and expertise.
* Accelerate shared business processes across organizational boundaries.
* Share business data without divulging sensitive information.
* Enable people to make better-informed decisions by presenting business-critical information in one central location.
* Provide a single, integrated platform to manage intranet, extranet, and Internet applications across the enterprise.

3.    Will SharePoint Portal Server and Team Services ever merge?

The products will come together because they are both developed by the Office team.

Office SharePoint Server 2007 & more


1.    Are there any browser recommendations?

Yes. Microsoft recommends using the following browsers for viewing and editing Windows SharePoint Services sites: Microsoft Internet Explorer 5.01 with Service Pack 2, Microsoft Internet Explorer 5.5 with Service Pack 2, Internet Explorer 6, Netscape Navigator 6.2 or later.

2.    What security levels are assigned to users?

Security levels are assigned by the administrator who is adding the user. There are four levels by default and additional levels can be composed as necessary.
* Reader - Has read-only access to the Web site.
* Contributor - Can add content to existing document libraries and lists.
* Web Designer - Can create lists and document libraries and customize pages in the Web site.
* Administrator - Has full control of the Web site.

3.    How secure are Windows SharePoint Services sites hosted by Microsoft?

Microsoft Windows SharePoint Services Technical security measures provide firewall protection, intrusion detection, and web-publishing rules. The Microsoft operation center team tests and deploys software updates in order to maintain the highest level of security and software reliability. Software hot-fixes and service packs are tested and deployed based on their priority and level of risk. Security related hot-fixes are rapidly deployed into the environment to address current threats. A comprehensive software validation activity ensures software stability through regression testing prior to deployment.

Saturday, March 10, 2012

Top 20 Question & Answers SharePoint


1.    What is Microsoft Windows Services?

Microsoft Windows Services is the engine that allows administrators to create Web sites for information sharing and document collaboration. Windows SharePoint Services provides additional functionality to the Microsoft Office System and other desktop applications, as well as serving as a plat form for application development. SharePoint sites provide communities for team collaboration, enabling users to work together on documents, tasks, and projects. The environment for easy and flexible deployment, administration, and application development.

2.    What is the relationship between Microsoft SharePoint Portal Server and Microsoft Windows Services?

Microsoft SharePoint Products and Technologies (including SharePoint Portal Server and Windows SharePoint Services) deliver highly scalable collaboration solutions with flexible deployment and management tools. Windows SharePoint Services provides sites for team collaboration, while Share Point Portal Server connects these sites, people, and business processes—facilitating knowledge sharing and smart organizations. SharePoint Portal Server also extends the capabilities of Windows SharePoint Services by providing organizational and management tools for SharePoint sites, and by enabling teams to publish information to the entire organization.

3.    Who is Office SharePoint Server 2007 designed for?

Office SharePoint Server 2007 can be used by information workers, IT administrators, and application developers.
is designed

SharePoint Basic Question & Answers Part 1


1.    What is SharePoint?

Portal Collaboration Software.

2.    What is the difference between SharePoint Portal Server and Windows SharePoint Services?

SharePoint Portal Server is the global portal offering features like global navigation and searching. Windows SharePoint Services is more content management based with document libraries and lists. You apply information to certain areas within your portal from Windows SharePoint Services or directly to portal areas.

3.    What is a document library?

A document library is where you upload your core documents. They consist of a row and column view with links to the documents. When the document is updated so is the link on your site. You can also track metadata on your documents. Metadata would consist of document properties.