Wednesday, October 9, 2013

Difference between Abstract Class VS Interaces

Abstract Class

  •    with keyword Abstract in the class Contain both abstract and non abstract methods. Abstract  methods does not contain implementaion in base classs only contains  method name with parameters with keyword abstract in the methods. Non Abstract methods contain implementation in the base Class itself.
  • Abstract method should be override in the derived class by defining it. 
  • A class can be inherited from only one abstract class.
  • Abstract class can't able to instantiate. It can be accessed through derived class objects.
  • Abstract class have access specifiers for Function/Properties/Methods
Interface
   
  • Interface is not a class it is a Entity defined by interfaces. Methods defined inside interface does not contain implementation only method  name with parameter. Classes which inherited interfaces all methods defined will get Implemented in the base class.
  • A class can have more than One Interfaces . It supports multiple inheritance.(C# does not support multiple inheritance.) 
  • Interface does not contain Access Specifier for Function/Properties/Methods default as Public.
  


LINQ IN SQL

LINQ - Language Integrated Query

  • Feature Introduced in Visual Studio 2008 
  • Supported from Visual Studio 2008 & later versions of visual Studio.
  • Used or Query the result set from  Objects/XML/ADO.Net (Object collection/Data Set /SQL Server/Entities/XML).
  • Using Linq 
For Querying result in our front end C# language support LINQ.

Sample Query for Linq


var q=(from item in TAA_Parcels
where item.IsDeleted==false
 select new{
                item.ParcelID,
                 item.ParcelNumber,
           }).ToList(); 
  
q.Dump();

Result Set



































INNER JOIN uisng  LINQ Query

from item in Metadatas 
 join item1 in BusinessRules on item.DatabaseID equals item1.DatabaseID
where item.DatabaseID == 1 orderby item.ReportTypeID 
select new
{
item.MetadataID,
item1.RuleName,
item.ReportTypeID,
item1.FormulaExpression

}



CROSS JOIN using LINQ

from meta in Metadatas
from type in  MetadataTypes
where meta.DatabaseID == 1 && meta.MetadataTypeID==1
select new
{
       meta.MetadataID,
       meta.MetadataTypeID,
       meta.DatabaseID,
       type.CreatedBy,
       type.MetadataTypeName
}