Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alertbox/snikt
Snikt! is a SQL data access helper to query and materialize data.
https://github.com/alertbox/snikt
c-sharp dotnet micro-orm microsoft snikt sql
Last synced: 28 days ago
JSON representation
Snikt! is a SQL data access helper to query and materialize data.
- Host: GitHub
- URL: https://github.com/alertbox/snikt
- Owner: alertbox
- License: mit
- Created: 2012-09-23T15:40:53.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2016-11-12T08:17:34.000Z (about 8 years ago)
- Last Synced: 2024-04-28T01:44:33.890Z (8 months ago)
- Topics: c-sharp, dotnet, micro-orm, microsoft, snikt, sql
- Language: C#
- Homepage:
- Size: 1.94 MB
- Stars: 3
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## SNIKT!
[![StackShare](https://img.shields.io/badge/tech-stack-0690fa.svg?style=flat)](https://stackshare.io/alertbox/snikt)
[![Gitter](https://badges.gitter.im/alertbox/snikt.svg)](https://gitter.im/alertbox/snikt?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Stories in Ready](https://badge.waffle.io/alertbox/snikt.svg?label=ready&title=Ready)](http://waffle.io/alertbox/snikt)Snkit! is nothing but a light-weight micro-ORM. Originally, it is the switchblade-sound of Wolverine's claws locking into place.
## OVERVIEW
I wrote Snikt! to take away the pain of data access logic.
* It is a simple Assembly you can refer in your Data Access Layer that will provide utilities, wrappers, and extensions to simplify work in the data access objects.
* Snikt! provides database connection lifetime management and execution store commands.
* It materialize CLR-types given a data reader as well as result set of a store command.
* It has templates and abstract classes for business entities, data access objects, and search query arguments.
* Snikt! has no database specific implementations. Technically, you should be able to use it on MySQL, SQL Server, or even on Oracle.## LICENSE
Snikt! code is free for commercial and non-commercial deployments and distribution. Snikt! is release under [MIT License](http://www.opensource.org/licenses/mit-license.php).## FEATURES
Snikt! provides 3 simple helpers:
* [Materializer.cs](https://github.com/kosalanuwan/snikt/blob/master/Snikt/Materializer.cs)
* [Database.cs](https://github.com/kosalanuwan/snikt/blob/master/Snikt/Database.cs)
* [DbConnectionFactory.cs](https://github.com/kosalanuwan/snikt/blob/master/Snikt/DbConnectionFactory.cs)### Map query results to a strong-typed list
```csharp
IDataReader queryResult = command.ExecuteReader();
Materializer categoryMaterializer = new Materializer(queryResult);
List categories = new List();
while (queryResult.Read())
{
categories.Add(categoryMaterializer.Materialize(queryResult));
}Assert.IsTrue(categories.Any());
```### Execute a Stored Procedure
```csharp
IDatabase db = new Database("name=DefaultConnection");List categories = db.SqlQuery("dbo.GetAllCategories").ToList();
Assert.IsTrue(categories.Any());
```### Execute a Stored Procedure that obtain Parameters
```csharp
IDatabase db = new Database("name=DefaultConnection");
var criteria = new { Id = 1 };List categories = db.SqlQuery("dbo.GetCategory", criteria).ToList();
foreach (Category cat in categories)
{
Assert.AreEqual(criteria.Id, cat.Id);
}
```### Provide DbContext as the Connection
```csharp
public class DbContextConnectionFactory : IDbConnectionFactory
{
public IDbConnection CreateIfNotExists(string nameOrConnectionString)
{
MiniNWDbContext dbContext = new MiniNWDbContext("name=DefaultConnection");
return dbContext.Database.Connection;
}
}IDatabase db = new Database("name=DefaultConnection", new DbContextConnectionFactory());
List categories = db.SqlQuery("dbo.GetAllCategories").ToList();
Assert.IsTrue(categories.Any());
```## OTHER RESOURCES
Snikt! is created to demonstrate How to apply some of the available .NET technologies with the Data Access Layer in Layered Architecture design pattern. The main focus of the specifications is How to code the Data Access Layer? and not the actual functionality of the chosen MiniNW application.* Snikt! has a comprehensive test project that demonstrates How Do I in [Specifications](https://github.com/kosalanuwan/snikt/tree/master/Snikt.Specifications).
* You can download the [Snikt! NuGet package](https://nuget.org/packages/Snikt/) from NuGet Gallery./KP
e: [email protected]
t: [@kosalanuwan](https://www.twitter.com/kosalanuwan)
b: http://kosalanuwan.tumblr.com