https://github.com/yysun/dragon
https://github.com/yysun/dragon
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yysun/dragon
- Owner: yysun
- License: ms-pl
- Created: 2012-01-19T04:21:22.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-01-19T04:54:34.000Z (over 13 years ago)
- Last Synced: 2024-12-04T20:18:02.504Z (6 months ago)
- Language: C#
- Homepage:
- Size: 113 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License.txt
Awesome Lists containing this project
README
Introduction
============
Dragon is a simplified ORM tool. It has similar syntax to Matrix.Data.Database, but maps to static types not dynamic. E.g.```C#
Database database = Database.Open("Users");
var users = database.Query("select UserId, Email from UserProfile where UserId=@UserId",
new { UserId = 2 }).ToList();
Assert.AreEqual(2, users[0].UserId);
Assert.AreEqual("[email protected]", users[0].Email);
```Database Methods
================
The Database Class has methods Open, Execute QueryValue and Query.* Open, opens database connection, the parameter can be a connection string, or a connection string name in app.config file or a registry path to a connection string.
* Execute, creates a command and runs ExecuteNonQuery.
* QueryValue, creates a command and runs ExecuteScalar.
* Query, creates a command with SQL statement(s) or stored procedure name and creates objects. The Query method supports up to 3 multiple record sets. The result objects are returned in a Tuple, E.g.```C#
Database database = Database.Open("Users");
var users = database.Query(
@"select * from dbo.UserProfile
select * from dbo.webpages_Membership
select * from dbo.webpages_Roles");Assert.AreEqual(1, users.Item1.ToList()[0].UserId);
Assert.AreEqual(0, users.Item2.Count());
Assert.AreEqual("Sysadmin", users.Item3.ToList()[0].RoleName);
```Source Code
===========
https://github.com/yysun/Dragon