11/18/2011

Why do we need LINQ?

LINQ: Language Integrated Query.

Queries are the one which retrieve data from a data source, SQL can be a data source or XML can be another data source.
SQL is the query type used to retrieve database data type from a database source.
Xquery is another type to retrieve xml data from xml data source.

So we developers have to learn different query types for each data formats,LINQ simplifies this situation by offering a consistent model for working with data across various kind of data format and data source.

In LINQ query you will be always working with 'Objects'. You use the same basic coding pattern to query data from XML,SQL,ADO.net ,.net collections etc..
                                                                                                                                       read more

11/07/2011

SharePoint 2010 Architecture Overview

SharePoint 2010 UI enhancements

SharePoint 2010 shipped with lot of UI enhancement they are:
  • Ribbon Toolbar
           Now SP 2010 has UI as like in other Microsoft products, with ribbon interface it is easy to work in SharePoint sites,document library,lists,calendar,and other items
  • AJAX enabled
          Most of the activities in SP 2010 are AJAX enabled, Inserting /Editing or deleting items in List or Document library actions are available in place and require no full page request.
  • Bread Crumbs
      Shows links in tree view structure and makes navigation much easier.
  • Developer dashboard
      Developer dashboard is for the developers to diagnose  and monitor page, it displays various database calls, webpart execution time, authenticates user, critical errors and various SP request object calls.
  • Pop-up dialog boxes
       In SharePoint 2007 whenever you do any activity like creating new list etc. it directs to new windows and we have to come back to the main list after its completion, to overcome page traversals , SP 2010 pops up a dialog instead of redirecting to new page 




10/03/2011

What is asmx file

.asmx is Web service file, which stands for Active Server Method file.

9/27/2011

Code Snippet to show Objects are reference types

The value of o2 changes dynamically when o1 is changed.


 Run the console project and see the result of object o2:



9/23/2011

.Net Interoperability


  • .Net framework supports interoperability.
  • Interoperability is the ability of two systems to communicate with each other, The first system could be built on .Net framework and the other system can be of some other technology.


.Net Interoperability is of two types:

  •  Managed code interoperability
  •  Unmanaged code interoperability

Manged code interoperability:
 Create a class library in c sharp, which has a method called Hello()



 Call the c sharp class library in VB project.



9/18/2011

Application of CSharp timer

We can user timers to periodically to check the server and the system is up and running

9/15/2011

Reflection example

Reflection is a feature in .Net which enables us to get some information about the object in runtime.That information contains data of the class.also it gets the name of the methods inside the class and constructor of the objects.
read more

9/14/2011

Difference between Array and Array List


  • An array can contain only one data type, while array list can contain any data type in the form of object.
  • With array you cannot dynamically increase or decrease the size of the array, but array list automatically increases the size, when any element or object is added.

Complete list of OOP terms

9/13/2011

When to use Interface and Abstract Class

  • Interface members cannot have a definition
  • All interface members should be implemented by the derived class
  • An abstract class can have an instance field in it. The derived classes can assess this field through the  base syntax. This is the key difference between abstract and interfaces.

Abstract class can contain non abstract method. 
  When we want that all subclass must implement all methods of 
base class ;In such situation use interface.In other hand
when we want only some method of base class in our subclass
then use base class as abstract class because abstract class
can contain non-abstract method.

Interfaces are used when we want classes should follow the 
rules strictly. Rules like naming coventions e.g. if in 
customer class one developer add method AddCustomer other 
developer while implementing Invoice class could write 
method name InvoiceAdd and also could change the Signiture 
rules. for addition of customer we have at client code as 
Cutomer.AddCustomer(A,B,C); and Invoice.InvoiceAdd(A,B)
To maintain uniformality if we declare interface and define 
method Add(A,B) in that interface and implement that 
interface in both the classes then the code will be uniform 
all over the classes where ever we have implemented 
interface and also all concrete classes must contain 
methods which are defined in the interfaces.



Interface:

–> If your child classes should all implement a certain
group of methods/functionalities but each of the child
classes is free to provide its own implementation then use
interfaces.

For e.g. if you are implementing a class hierarchy for
vehicles implement an interface called Vehicle which has
properties like Colour MaxSpeed etc. and methods like
Drive(). All child classes like Car Scooter AirPlane
SolarCar etc. should derive from this base interface but
provide a seperate implementation of the methods and
properties exposed by Vehicle.

–> If you want your child classes to implement multiple
unrelated functionalities in short multiple inheritance use
interfaces.

For e.g. if you are implementing a class called SpaceShip
that has to have functionalities from a Vehicle as well as
that from a UFO then make both Vehicle and UFO as interfaces
and then create a class SpaceShip that implements both
Vehicle and UFO .

Abstract Classes

–> When you have a requirement where your base class should
provide default implementation of certain methods whereas
other methods should be open to being overridden by child
classes use abstract classes.

For e.g. again take the example of the Vehicle class above.
If we want all classes deriving from Vehicle to implement
the Drive() method in a fixed way whereas the other methods
can be overridden by child classes. In such a scenario we
implement the Vehicle class as an abstract class with an
implementation of Drive while leave the other methods /
properties as abstract so they could be overridden by child
classes.

–> The purpose of an abstract class is to provide a common
definition of a base class that multiple derived classes can
share.

For example a class library may define an abstract class
that is used as a parameter to many of its functions and
require programmers using that library to provide their own
implementation of the class by creating a derived class.
Use an abstract class

    * When creating a class library which will be widely
distributed or reused—especially to clients, use an abstract
class in preference to an interface; because, it simplifies
versioning. This is the practice used by the Microsoft team
which developed the Base Class Library. ( COM was designed
around interfaces.)

    * Use an abstract class to define a common base class
for a family of types.

    * Use an abstract class to provide default behavior.

    * Subclass only a base class in a hierarchy to which the
class logically belongs.

 
Use an interface

    * When creating a standalone project which can be
changed at will, use an interface in preference to an
abstract class; because, it offers more design flexibility.

    * Use interfaces to introduce polymorphic behavior
without subclassing and to model multiple
inheritance—allowing a specific type to support numerous
behaviors.

    * Use an interface to design a polymorphic hierarchy for
value types.

    * Use an interface when an immutable contract is really
intended.

    * A well-designed interface defines a very specific
range of functionality. Split up interfaces that contain
unrelated functionality.




9/12/2011

When to use Interface

If the requirement is like that something in your design changes frequently then go for interfaces instead of classes .


                                                                                                                                                                              read more

9/02/2011

C# Constants

  • Constants are immutable values which are known at the compile time.
  • They do not change for the life of the program
  • C# built in types may be declared as constants
  • User-defined types including Classes, structs , arrays cannot be 'const'
  • C # does not support const methods,properties or events
  • When a complier encounters a const identifier in c# source code, it substitutes the literal value into the intermediate language(IL) code the produces 
  • Because there is no variable address associated with a constant at run time.
  • Constant fields cannot be passed by reference 
  • Constants are marked by public,private,protected,internal.                                                                      
                                                                                                                                                    read more

What are the types of C# members

Types of C# members:


  • Fields
  • Constants
  • Properties
  • Methods
  • Constructors
  • Destructors
  • Events
  • Indexers
  • Operators
  • Nested Types


8/26/2011

Why to use DLL

A DLL is a collection of small programs, which can be called when needed by a larger program that is running in the computer. The small program that lets the larger communicate with a specific device such as printer or scanner is often packged as a a DLL program.

The advantages of DLL:
DLL's don't get loaded in RAM together with the program , so space is saved in RAM(Random Access Memory).

When and if a DLL file is needed, then it is loaded and run. For example, as long as a user of Microsoft Word is editing a document, the printer DLL file does not need to be loaded into RAM. If the user decides to print the document, then the Word application causes the printer DLL file to be loaded and run.

8/24/2011

Why do we need Try-Finally block


The output that the code in the finally block will be executed after throwing the exception. However, the last statements in the program that followed the finally block will not be executed. This means that the exception
prevents control from being transferred to any part of the program except the finally block.



using System;
public class MyClass
{
static void Main()

{
string myString = "Finally";
object myObject = myString;
try
{
// The following conversion is invalid.
// It throws an exception.
int myInt = (int)myObject;
}
finally
{
// The code in this block is always executed:
Console.WriteLine("The program continues and ends here:");
Console.WriteLine("My String is: {0}", myString);
}
// The following code will not be executed:
Console.WriteLine("Hello again!");
}
}

It is also used for cleaning up the resource, like to close the open file stream..

7/31/2011

How to create an Assembly in .Net

I will show here how to create a simple dll in .net using visual studio 2010, and to link it with other exe.
This may help a .net newbie like me.

Step 1: Create a class library



Step 2: Create a Console application





Step 3: Link the dynamic library

Use add() and sub() methods


Step 4:  Build and Run the project






read more 

7/28/2011

Learn Microsoft's PowerShell

Nice tutorial on Power shell: read

Why do we need PowerShell:

 Traditionally, an Administrator would launch the GUI, select the service, and then either stop or start it. Doesn't seem like a big deal until you are asked to stop a service on multiple computers. Through PowerShell Scripting you will be able to start, stop, and change status types of a service on multiple computers without much effort. Write a script, run-it, and then kick you feet up on the desk.



6/03/2011

Step by Step WCF example

Step by step procedure to create WCF:

A.Creating the service (Server side)

Step 1: Open Visual Studio 2010 and create project ,choose  "Windows Service  Application", and give a name to your project say MyService.

Step 2: Open IService.cs  , in that you can see [ServiceContract] where your intetface name is declared and [OperationContract] here you function contract should be defined here (note: delete the default functions if they are not needed), initialize you addData function here




Step 3: Open Service1.svc.cs and add the code for the addData function, ( note: delete the default functions if they are not needed)

                                  

Step 4: Declare your endpoint in web.config file add the below code which is in  bold and Italics.
                                 
                                   

Step 5:Save the project and run it

                                       
B. Creating the client to consume the service (Client side):

Step 1: Open another Visual studio 2010 , create a new ASP.net web application.right click the project and go to 'Add Service reference' ,copy and paste the service  url and press OK

Step 2: Open Default.aspx , create a simple button and lable controls

Step 3: Double click the button and add this following code

                                         

Ste 4: Build and run the project ,now your client has comsumed the services!!

                                          

read more

msdn :http://msdn.microsoft.com/en-us/library/ms734712.aspx 

5/29/2011

What is C Sharp Using statement

The Using statement in C# allows you to define the scope of an object lifetime, when the end of the using satament is reached  the object Dispose() will be called immediatly.

using (SqlConnection conn = new SqlConnection(connString))
{
     SqlCommand cmd = conn.CreateCommand();
     cmd.CommandText = "SELECT * FROM Customers";
     conn.Open();
     using (SqlDataReader dr = cmd.ExecuteReader()) {
          while (dr.Read())
          // Do Something...
     }
}

This is extremly useful when we need to release a resourece intensive object, like database connection object or a transaction scope                 
                                                                          read more

5/19/2011

APS.net Dropdownlist OnSelectIndex Changed Event

The OnSelectedindexChanged event handler of ASp.net DropDownlist Control enables you to handel the click event of list items at server side that is raised at hte time when user clicks to select a list item of dropdownlist control  read more

What is Active Directory


  • Active Directory stores information about Network Components
  • It allows clients to find objects within the namespace.
  • The term namespace  refers to the area in which the network components are located
  • For example the table of content of a book forms a namespace in which chapters can be resolved to page numbers,
  • DNS is a namespace which resolves host name to IP address
  • Telephone book provides the namespace for resolving names to phone numbers .
  • Active directory provides a namespace for resolving the name of the network objects to objects themselves
  • Every thing that Active directory tracks is considered as an object
  • An object is any user,system,resource or services tracked in active directory
http://wiki.answers.com/Q/What_is_active_directory_and_how_is_it_used
                                                                                                                                                read more

How to force uninstall a program you cannot uninstall

  1. Click Start and choose Run in the menu (If you're using Windows Vista then press Win+R on your keyboard).
  2. Type regedit and hit Enter.
  3. On the left side is the registry settings tree, use it to go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
  4. Inside that key you'll find a lot of keys that belong to different programs. Some are named after the program's name, others as a mix of numbers and letters that makes no sense. Look through each of them until you find one that has the key DisplayName (on the right) with your program's name in it.
  5. Notice the key UninstallString - this key points to the uninstall program, and the log file usually resides in the same folder as that program.
  6. If you delete the key in which you've found the DisplayName key with the value equal to your program's name, then your program won't appear on the Add/Remove programs list

5/18/2011

What is CAML

Collaborative Application Markuup Languae is the XML-based language that is used to build and customize web sites based on Sharepoint team Services

CAML can be used to do the following:
 Provide schema definition to the web site provisioning system about how the site looks and acts
 Define views and forms for data and page rendering or execution.
Pulling a value from a particular form

Why do we use CAML:
CAML allows you the ultimate flexibility and extensibility with your Web sites based on SharePoint Team Services from Microsoft. If you want to make a universal change to all the sites that you are creating within your company — for instance, you want to change the logo to match your own company logo, or you want to add an Employee ID field to your document libraries — you must use CAML to do it

Location of CAML:  ( read more )

CAML Query tool :
Collaborative Application Markup Language (CAML) is an XML-based language that developers can use to create custom views and query SharePoint lists. Because it can be difficult to write anything other than basic queries, many tools have been developed to simplify this task. Several of these tools allow developers to write CAML queries within a designer. This is similar to the way developers write SQL queries for many commonly used databases.
  
 download