https://github.com/rocherkong/bara
micro orm for .net cross-platform.Bara is a .Net library for Orm. Bara provides quick access to DataBase. Also it is a cross-platform orm which is written by .net Standard version 1.4 . You Can use it on .net Framwork platform or .net Core platform with Any type DataBase which Dapper Support.
https://github.com/rocherkong/bara
dapper dataaccess database dotfiles mybatis mysql oracle orm sql
Last synced: 4 months ago
JSON representation
micro orm for .net cross-platform.Bara is a .Net library for Orm. Bara provides quick access to DataBase. Also it is a cross-platform orm which is written by .net Standard version 1.4 . You Can use it on .net Framwork platform or .net Core platform with Any type DataBase which Dapper Support.
- Host: GitHub
- URL: https://github.com/rocherkong/bara
- Owner: RocherKong
- Created: 2017-07-14T02:41:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-26T13:41:47.000Z (over 7 years ago)
- Last Synced: 2025-02-01T00:51:05.508Z (about 1 year ago)
- Topics: dapper, dataaccess, database, dotfiles, mybatis, mysql, oracle, orm, sql
- Language: C#
- Homepage:
- Size: 3.6 MB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
``` html
____
| _ \
| |_) | __ _ _ __ __ _
| _ < / _` || '__|/ _` |
| |_) || (_| || | | (_| |
|____/ \__,_||_| \__,_|
```
# Bara
| Codacy | Appveyor | NuGet | Gitchat |
|--------|----------|-------|---------|
|[](https://www.codacy.com/app/kx.1990/Bara?utm_source=github.com&utm_medium=referral&utm_content=RocherKong/Bara&utm_campaign=badger)|[](https://ci.appveyor.com/project/RocherKong/bara/branch/master)| [](https://www.nuget.org/packages/Bara/)|[](https://gitter.im/ORM-Bara/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link)|
Bara is a .Net library for Orm. Bara provides quick access to DataBase. Also it is a cross-platform orm which is written by .net Standard version 1.4 . You Can use it on .net Framwork platform or .net Core platform with Any type DataBase which Dapper Support.
## Features
* Using Dapper for DataMapping and DataAccess.
* Using Xml Config and Manage your sql like Ibatis.
* Hot Update Sql when you changed your sql sentence.
## Installing
Just install the [Bara NuGet package](http://www.nuget.org/packages/Bara/):
```
PM> Install-Package Bara
```
If your want Bara Extension.(A collection of commonly used methods already included)
```
PM> Install-Package Bara.DataAccess
```
## How To Use After Intalled
### 1.Add **BaraMapConfig.xml** To Root Path.
> * Config whether the config need Watched.It will be update when setting true.
> * Config DataBase ConnectString
> * Split Writen DB and Read DB. Specify each Database Weight which indicate the Access probability.
> * Specify the ParameterPrefix(MSSQL:'@',Mysql:'#'...)
> * Config your Maps which your sql in.
```xml
Oracle:(Reference ODP Library From ./Doc/OracleDataProvider)
```
### 2.Config BaraMap Xml Files(eg:**T_Test.xml** in Root-Folder Maps)
### 3.Register To DI in Startup.cs
```c#
services.AddSingleton(MapperContainer.Instance.GetBaraMapper());
```
### 4.Use Any Where
#### 4.1 GetEntity
```c#
var mapper = new BaraMapper();
var result = mapper.QuerySingle(new Core.Context.RequestContext
{
SqlId = "GetEntity",
Scope = "T_Test",
Request = new { Id = 1 }
});
```
#### 4.2 QueryList
```c#
var list= mapper.Query(new Core.Context.RequestContext
{
SqlId="GetList",
Scope="T_Test",
});
```
#### 4.3 Add
```c#
int i = mapper.Execute(new Core.Context.RequestContext
{
Scope = "T_Test",
SqlId = "Insert",
Request = new { Id = 4, Name = "Rocher4" }
});
```
#### 4.4 Update
```c#
int i = mapper.Execute(new Core.Context.RequestContext
{
Scope = "T_Test",
SqlId = "Update",
Request = Entity
});
```
## Cache Config
### Firstly You Need Config Cache in BaraMap file .
```xml
```
### Secondly You Need Relate Cache to your statement.
```xml
SELECT Top 10 T.* From T_Test T With(NoLock)
```
### After config Metioned.The Same-Query after first Query Will fetch Data from Cache.Also it will dismiss after Insert or Update method executed.
## Next Step
* 0.Tags(Logic bit operator)
* 1.Test
* 2.Test Compare
* 3.redis cache
* 4.zookeeper(options)
* 5.add Doc
* 6.Release
## Tips
* Can DataAccess be more Simple?(Auto Generate dao Code for Mapping Method Name.)
## Thanks
[Ahoo-Wang/SmartSql](https://github.com/Ahoo-Wang/SmartSql/):