Dappir 1.0.4

more extensions for dapper

There is a newer version of this package available.
See the version list below for details.
Install-Package Dappir -Version 1.0.4
dotnet add package Dappir --version 1.0.4
<PackageReference Include="Dappir" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dappir --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Dappir - more extensions for dapper

=&gt;This is a small tribute to our developer department DAPI; Why the name Dappir?: Dapper + Dapi = Dappir. Departamento de Aprimoramento da Primeira Instância - DAPI

Features

Dappir contains a number of helper methods for inserting, getting,
updating and deleting records and on cascade too \o/.

You remember of Contrib, ow yeah, its true, but is not, haha!!!

This is for SQL SERVER still, but we want them for all data bases. do you want help us, do fork now.

The full list of extension methods in Dappir on 'IDbTransaction' right now are:


//we are using this litle interface for facibily, all methods have this interface like constraint
public interface IModel { }

//now we have this methods

//inserts
void Insert<TModel>(TModel entity);
void InsertAll<TModel>(IEnumerable<TModel> listEntity);
void InsertOnCascade<TModel>(TModel entity);

//selects
IEnumerable<TModel> SelectAll<TModel>();
IEnumerable<TModel> Select<TModel>(object filterDynamic);
TModel Select<TModel>(int key);
TModel SelectOnCascade<TModel>(int key);

//updates
void Update<TModel>(TModel entity);
void UpdateAll<TModel>(IEnumerable<TModel> listEntity);
void UpdateOnCascade<TModel>(TModel entity);

//deletes
void Delete<TModel>(int key);
void Delete<TModel>(TModel entity);
void DeleteAll<TModel>(IEnumerable<TModel> listEntity);
void DeleteOnCascade<TModel>(int key);

For these extensions to work, the entity in question MUST have a
key property decorate with [Column(IsPrimaryKey = true)].

public class Car
{
    [Column(IsPrimaryKey = true)]
    public int CarId { get; set; }
    public string Name { get; set; }
}

For your entity working with cascade, you must decorate yours property on [Association].

public class Car
{
    [Column(IsPrimaryKey = true)]
    public int CarId { get; set; }
    public string Name { get; set; }
    
    [Association]
    public Carmaker Maker { get; set; }

    [Association]
    public List<Dealership> Dealerships { get; set; }
}

public class Carmaker
{
    [Column(IsPrimaryKey = true)]
    public int CarmakerId { get; set; }
    public int CarId { get; set; }
    public string Name { get; set; }
}

public class Dealership
{
    [Column(IsPrimaryKey = true)]
    public int DealershipsId { get; set; }
    public int CarId { get; set; }
    public string Name { get; set; }
}

CarId Look this is the relationship between entities.

Select methods

Get one specific entity based on id

var car = transaction.Select<Car>(1);

var carmaker = transaction.Select<Carmaker>(1);

var listDealerships = transaction.Select<Dealership>(new { CarId = 1 });

or a list of all entities in the table.

var listDealerships = transaction.SelectAll<DealershipCar>();

or still you can select on cascade, look that:

var car = transaction.SelectOnCascade<Car>(1);

var carmaker = car.Maker;

var listDealerships = car.Dealerships;

\o/ its amazing Yeah, cascade is very nice.

Insert methods

Insert one entity

var car = new Car { Name = "520" };
car.Maker = new Carmaker { "Volvo" };
car.Dealerships = new List<Dealership> 
{ 
    new Dealership { Name = "Veronica Vehicles" }, 
    new Dealership { Name = "Heavy Loader Trucks" } 
};

transaction.Insert(car);

car.Maker.CarId = car.CarId;

transaction.Insert(car.Maker);

car.Dealerships.ForEach(x =>
{
    x.CarId = car.CarId;
    transaction.Insert(x);
})

or a list of entities.

var car = new Car { Name = "520" };
car.Maker = new Carmaker { "Volvo" };
car.Dealerships = new List<Dealership> 
{ 
    new Dealership { Name = "Veronica Vehicles" }, 
    new Dealership { Name = "Heavy Loader Trucks" } 
};

transaction.Insert(car);

car.Maker.CarId = car.CarId;

transaction.Insert(car.Maker);

car.Dealerships.ForEach(x => x.CarId = car.CarId);

transaction.InsertAll(car.Dealerships);

or insert with cascade, more easy:

var car = new Car { Name = "520" };
car.Maker = new Carmaker { "Volvo" };
car.Dealerships = new List<Dealership> 
{ 
    new Dealership { Name = "Veronica Vehicles" }, 
    new Dealership { Name = "Heavy Loader Trucks" } 
};

transaction.InsertOnCascade(car);

Update methods

Update one specific entity

transaction.Update(new Car() { CarId = 1, Name = "Saab" });

or update a list of entities.

transaction.UpdateAll(cars);

and ofcourse, cascade.

transaction.UpdateOnCascade(car);

Delete methods

Delete an entity by the specified [Column(IsPrimaryKey = true)] property

transaction.Delete(new Car() { CarId = 1 });
transaction.Delete<Car>(1);

a list of entities

transaction.DeleteAll(cars);

and our good and friend old cascade

pay attention to the external relations with the car class on use of cascade.

transaction.DeleteOnCascade<Car>(1);

Special Attributes

Dappir makes use of some optional attributes:

  • [Table(&quot;Tablename&quot;)] - use another table name instead of the name of the class

    [Table ("emps")]
    public class Employee
    {
        [Column(IsPrimaryKey = true)]
        public int EmployeeId { get; set; }
        public string Name { get; set; }
    }
    

if dependencies do not resolve correctly, copy and paste theDappirHelperExtensionsclass into your project

Dappir - more extensions for dapper

=&gt;This is a small tribute to our developer department DAPI; Why the name Dappir?: Dapper + Dapi = Dappir. Departamento de Aprimoramento da Primeira Instância - DAPI

Features

Dappir contains a number of helper methods for inserting, getting,
updating and deleting records and on cascade too \o/.

You remember of Contrib, ow yeah, its true, but is not, haha!!!

This is for SQL SERVER still, but we want them for all data bases. do you want help us, do fork now.

The full list of extension methods in Dappir on 'IDbTransaction' right now are:


//we are using this litle interface for facibily, all methods have this interface like constraint
public interface IModel { }

//now we have this methods

//inserts
void Insert<TModel>(TModel entity);
void InsertAll<TModel>(IEnumerable<TModel> listEntity);
void InsertOnCascade<TModel>(TModel entity);

//selects
IEnumerable<TModel> SelectAll<TModel>();
IEnumerable<TModel> Select<TModel>(object filterDynamic);
TModel Select<TModel>(int key);
TModel SelectOnCascade<TModel>(int key);

//updates
void Update<TModel>(TModel entity);
void UpdateAll<TModel>(IEnumerable<TModel> listEntity);
void UpdateOnCascade<TModel>(TModel entity);

//deletes
void Delete<TModel>(int key);
void Delete<TModel>(TModel entity);
void DeleteAll<TModel>(IEnumerable<TModel> listEntity);
void DeleteOnCascade<TModel>(int key);

For these extensions to work, the entity in question MUST have a
key property decorate with [Column(IsPrimaryKey = true)].

public class Car
{
    [Column(IsPrimaryKey = true)]
    public int CarId { get; set; }
    public string Name { get; set; }
}

For your entity working with cascade, you must decorate yours property on [Association].

public class Car
{
    [Column(IsPrimaryKey = true)]
    public int CarId { get; set; }
    public string Name { get; set; }
    
    [Association]
    public Carmaker Maker { get; set; }

    [Association]
    public List<Dealership> Dealerships { get; set; }
}

public class Carmaker
{
    [Column(IsPrimaryKey = true)]
    public int CarmakerId { get; set; }
    public int CarId { get; set; }
    public string Name { get; set; }
}

public class Dealership
{
    [Column(IsPrimaryKey = true)]
    public int DealershipsId { get; set; }
    public int CarId { get; set; }
    public string Name { get; set; }
}

CarId Look this is the relationship between entities.

Select methods

Get one specific entity based on id

var car = transaction.Select<Car>(1);

var carmaker = transaction.Select<Carmaker>(1);

var listDealerships = transaction.Select<Dealership>(new { CarId = 1 });

or a list of all entities in the table.

var listDealerships = transaction.SelectAll<DealershipCar>();

or still you can select on cascade, look that:

var car = transaction.SelectOnCascade<Car>(1);

var carmaker = car.Maker;

var listDealerships = car.Dealerships;

\o/ its amazing Yeah, cascade is very nice.

Insert methods

Insert one entity

var car = new Car { Name = "520" };
car.Maker = new Carmaker { "Volvo" };
car.Dealerships = new List<Dealership> 
{ 
    new Dealership { Name = "Veronica Vehicles" }, 
    new Dealership { Name = "Heavy Loader Trucks" } 
};

transaction.Insert(car);

car.Maker.CarId = car.CarId;

transaction.Insert(car.Maker);

car.Dealerships.ForEach(x =>
{
    x.CarId = car.CarId;
    transaction.Insert(x);
})

or a list of entities.

var car = new Car { Name = "520" };
car.Maker = new Carmaker { "Volvo" };
car.Dealerships = new List<Dealership> 
{ 
    new Dealership { Name = "Veronica Vehicles" }, 
    new Dealership { Name = "Heavy Loader Trucks" } 
};

transaction.Insert(car);

car.Maker.CarId = car.CarId;

transaction.Insert(car.Maker);

car.Dealerships.ForEach(x => x.CarId = car.CarId);

transaction.InsertAll(car.Dealerships);

or insert with cascade, more easy:

var car = new Car { Name = "520" };
car.Maker = new Carmaker { "Volvo" };
car.Dealerships = new List<Dealership> 
{ 
    new Dealership { Name = "Veronica Vehicles" }, 
    new Dealership { Name = "Heavy Loader Trucks" } 
};

transaction.InsertOnCascade(car);

Update methods

Update one specific entity

transaction.Update(new Car() { CarId = 1, Name = "Saab" });

or update a list of entities.

transaction.UpdateAll(cars);

and ofcourse, cascade.

transaction.UpdateOnCascade(car);

Delete methods

Delete an entity by the specified [Column(IsPrimaryKey = true)] property

transaction.Delete(new Car() { CarId = 1 });
transaction.Delete<Car>(1);

a list of entities

transaction.DeleteAll(cars);

and our good and friend old cascade

pay attention to the external relations with the car class on use of cascade.

transaction.DeleteOnCascade<Car>(1);

Special Attributes

Dappir makes use of some optional attributes:

  • [Table(&quot;Tablename&quot;)] - use another table name instead of the name of the class

    [Table ("emps")]
    public class Employee
    {
        [Column(IsPrimaryKey = true)]
        public int EmployeeId { get; set; }
        public string Name { get; set; }
    }
    

if dependencies do not resolve correctly, copy and paste theDappirHelperExtensionsclass into your project

  • .NETFramework 3.5

  • .NETFramework 4.0

  • .NETFramework 4.6

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.6 442 11/8/2017
1.1.5 324 11/7/2017
1.0.5 479 10/28/2017
1.0.4 358 10/28/2017
1.0.3 330 10/28/2017
1.0.2 338 10/28/2017
1.0.1 384 10/28/2017
1.0.0 342 10/28/2017