asifashraf.com (from Asif Ashraf MCPD, MCAD.NET)

StartCricket
About me
First Click DAL
ASP.NET3.5Hosting
Geo News
Sama Tv Live
Duniya TV Online
Express News Live
National Geo. Ch. Live
Cartoon Network +
Channel 5 Live
Royal News Live
GeoNs. Small
Contact me

First Click DAL


First Click DAL is a solution for keeping your Data Access Layer synchronized. The only First CLICK data access layer which guarantees all possible query solutions. Including Models(Entities), and their controView/Edit Sourcellers, accessible from a central repository. Extremely easy to integrate and use. Leaves unlimited Data Access options to create a wonderful Business Logic Layer.

Try it once! We bet you would not breath without this after you will have used it.

This can be used on any .NET application like
  • Web Forms
  • Windows Forms
  • Windows Service
  • Web Services

Requires
.NET Framework 3.5

We also provide .NET Framework 3.5 Full Trust Hosting. Click the menu ASP.NET3.5 Hosting.

Contact for order or more detail
asif@asifashraf.com



Samples


using System;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

usingAutoWorkShop.Repository;

 

namespaceAutoWorkShop.BLL

{

   public partial class TechnicalService

    {

        //declare DB

        AutoWorkShopDBworkshopDB;

        //declarerepository class

        //repositoryclass exposes ALL methods to control the entities

        IAutoWorkShopRepository    centralRepository;       

 

        //defaultconstructor

        publicTechnicalService()

        {

            //initliazedb

            workshopDB = new AutoWorkShopDB(@"server=.;database=autoworkshop;userid=sa;password=abcdef");

            centralRepository = new SqlAutoWorkShopRepository(workshopDB);           

        }

 

       //add vehicle

       //do not askfor entity

       //ask forparameters

       //returnentity(not void)

       public Vehicle CreateVehicle(stringcarMake, string carModel

           , intcustomerId, string regNo)

       {

           //SQLQuery

           //INSERTINTO Vehicles...

 

           //use newconstructor

           Vehiclev = new Vehicle

           {

                //pressspace for fields

                //usecomma for seperation

                 CarMake = carMake,

                  CarModel = carModel,

                   CustomerId = customerId,

                    RegistrationNo = regNo

           };

           //saveentity

           centralRepository.SaveVehicle(v);

           returnv;

       }

 

 

       //Save method

       public void SaveVehicle(Vehiclev)

       {

           //autohandles INSERT , UPDATE

           centralRepository.SaveVehicle(v);

       }

 

       //Delete byentity

       public void DeleteVehile(Vehiclev)

       {

           //Deleteentity

           //SQLQUERY

           //Deletefrom Vechiles where RegNo == @regNo

           //--RegNois prikary key column

           //when youdelete an entity it will by deleted by primary key

           centralRepository.DeleteVehicle(v);

       }

 

 

       //Delet byPrimary Key BLL method

       public void DeleteVehicle(stringregNo)

       {

           //SQLQUERY

           //Deletefrom Vechiles where RegNo == @regNo

           //--RegNois prikary key column

 

           //Deleteby primary key

           Vehiclev = centralRepository.GetVehicleByPK(regNo);

           centralRepository.DeleteVehicle(v);

       }

 

 

       //Get AllMethod

       public IEnumerable<Vehicle>GetAllVehicles()

       {

           //SQLQuery

           //Select *from Vehicles

          

           //declarea collection of vehicles

           IEnumerable<Vehicle> all;

          

           //Not fillthis collection with different styles

           //the sameSQL will be executed in all styles

           //Allstyles do the same, just different ways to write

           //usewhichever seems nice to you

 

           //1.Repository Method Style

           all =centralRepository.GetVehicles();

 

           //2. LinqStyle to do the same work

           all = fromr in centralRepository.GetVehicles()

                  selectr;

          

           returnall;

       }

 

       //Get byprimary key

       public Vehicle GetVehicleByRegNo(stringregNo)

       {

           //SQLQuery

           //Select *from Vehicles where regNo = @regNo

           //--regNois primary key column

 

           //declarea vehicles variable

           Vehiclev;

              

           //get thisvariable by different styles

           //usewhichever seems easier

 

           //1. byrepo method style

           v =centralRepository.GetVehicleByPK(regNo);

 

           //2. bylinQ style

           v = (fromr in centralRepository.GetVehicles()

                   wherer.RegistrationNo == regNo

                   selectr).Single<Vehicle>();

 

           //3. byFilter style

           v = (centralRepository.GetVehicles()

                       .ByRegistrationNo(regNo)).Single<Vehicle>();

 

           //4. byWhere Method style

           v = centralRepository.GetVehicles()

               .Where<Vehicle>(veh=> veh.RegistrationNo == regNo)

               .Single<Vehicle>();

 

           returnv;

       }

 

       //Multiplefilter conditions using AND oprator

       public IEnumerable<Vehicle>GetVehByMakeAndModel(string make, string model)

       {         

          

           //SQLQUERY

           //select *from vechiels where carmake = @make AND carModel = @model

 

           IEnumerable<Vehicle> v;

 

           //1. linqmethod

           v = fromr in centralRepository.GetVehicles()

               wherer.CarMake == make

               && r.CarModel == model

               selectr;

 

           //2.filter method

           v = centralRepository.GetVehicles()

               .ByCarMake(make)

               .ByCarModel(model);

          

           //3. wheremethod

           v = centralRepository.GetVehicles()

               .Where<Vehicle>(veh => veh.CarMake == make

               && veh.CarModel ==model);

          

           returnv;

       }

 

       //Multiplefilter conditions using OR oprator

       public IEnumerable<Vehicle>GetVehByMakeOrModel(string make, string model)

       {

           IEnumerable<Vehicle> v;

           //SQLQUERY

           //select *from vechiels where carmake = @make OR carModel = @model

 

           //1. linqmethod

           v = fromr in centralRepository.GetVehicles()

               wherer.CarMake == make

               || r.CarModel == model

               selectr;

           

           //**FilterMethod NOT Available for OR operator**

 

           //2. wheremethod

           v = centralRepository.GetVehicles()

               .Where<Vehicle>(veh => veh.CarMake == make

               || veh.CarModel == model);

           return v;

       }

 

 

       //ShortConstructor single column

       public IEnumerable<string>GetRegNosByCustId(int custId)

       {

           //SQLQuery

           //SelectRegNo from vehicles where customerId = @custId

 

           IEnumerable<string> regNumbers = fromv in centralRepository.GetVehicles()

                                            where v.CustomerId == custId                                           

                                            select v.RegistrationNo;

           returnregNumbers;

       }     

 

       //ShortConstructor multiple column using anonymous type

       public void UsingAnonymousTypes(intcustId)

       {

           //SelectRegNo, Make, Model from vehicles where customerId = @custId

 

           //1. LinQStyle

           varregNos = from v incentralRepository.GetVehicles()

                        where v.CustomerId == custId

                        select new {

                        RegistrationNumber =v.RegistrationNo,

                        Make = v.CarMake,

                        Model = v.CarModel          

                        };

 

           //use theanonymous type

           foreach(var v inregNos)

           {

               stringregNo = v.RegistrationNumber;

               stringmake = v.Make;

               stringmodel = v.Model;

           }

       }

 

       //ShortConstructor multiple column returning a defined Type

      

       //define ashort type

       public class ShortVehicle

       {

           publicstring reg { get;set; }

           publicstring make { get;set; }

           publicstring model { get;set; }

       }

       //return theshort type

       public IEnumerable<ShortVehicle>GetShortVehicles(int custId)

       {

           //SQLQuery

           //SelectRegNo, Make, Model from vehicles where customerId = @custId

 

           //1. LinqStyle

           IEnumerable<ShortVehicle> shortCars = from v incentralRepository.GetVehicles()

                        where v.CustomerId == custId

                        select new ShortVehicle

                        {

                         reg =v.RegistrationNo,

                          make = v.CarMake,

                           model = v.CarModel

                        };

 

           returnshortCars;

       }

   

       //Aggregates

      

       //max customerid from vehicles

       public int GetAggregate()

       {

           intagg = 0;

 

           //selectmax(custId) from vehicles

           agg = (fromv in centralRepository.GetVehicles()

                  selectv.CustomerId).Max<int>();

 

           //selectcount(custId) from vehicles

           agg = (fromv in centralRepository.GetVehicles()

                  selectv.CustomerId).Count<int>();

           

           //selectmin(custId) from vehicles

           agg = (fromv in centralRepository.GetVehicles()

                  selectv.CustomerId).Min<int>();

 

         returnagg;

       }

 

    }

}