Coder Social home page Coder Social logo

gutaifm / databaseexecutors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from icoxfog417/databaseexecutors

0.0 1.0 0.0 2.51 MB

Simple And Functional Database Access Library for C# / VB.NET

Home Page: http://icoxfog417.github.io/DataBaseExecutors/Index.html

Visual Basic 100.00%

databaseexecutors's Introduction

DataBaseExecutors

DataBaseExecutors is simple database access tool for .NET.
You don't need to use DataReader or DataAdapter any longer . Just write SQL.

API Documents is Here
Download from Nuget

Officialy supports Oracle and SqlServer.

Related Repositories

How to use

Select

Dim db As New DBExecution(ConnectionName)
Dim table As DataTable = db.sqlRead("SELECT * FROM tab")

Select Scalar

Dim db As New DBExecution(ConnectionName)
Dim count As Integer = db.sqlReadScalar(Of Integer)("SELECT COUNT(*) FROM tab")

Functional Recordset processing

  • Make xml of users (<users><user>Mike</user> ... </users>)
Dim db As New DBExecution(ConnectionName)
Dim xml As String = db.sqlReadToString("SELECT * FROM tab ",Address Of Me.fetch) 'apply function to each record

Private Function fetch(ByVal reader As DbDataReader, ByVal counter As Long) As String
  Return "<user>" + reader.GetStringOrDefault("NAME") + "</user>"
End Function
  • Make list of user
Dim db As New DBExecution(ConnectionName)
Dim users As List(Of User) = db.sqlRead(Of User)("SELECT * FROM tab ",Address Of Me.createUser)

Private Function createUser(ByVal reader As DbDataReader, ByVal counter As Long) As User
  Return New User(reader.GetIntegerOrDefault("ID"),reader.GetStringOrDefault("NAME"))
End Function

Select 1 row as dictionary of column name and value

Dim db As New DBExecution(ConnectionName)
Dim user As Dictionary(Of String,String) = db.sqlReadOneRow("SELECT * FROM tab WHERE ID = 1")

Execute Query(UPDATE/INSERT)

Dim db As New DBExecution(ConnectionName)
db.addFilter("pid", 10)
db.addFilter("pName", "Mike")
db.sqlExecution("UPDATE tab SET NAME = :pName WHERE ID = :pId")

Execute by DataTable

Dim db As New DBExecution(ConnectionName)
db.importTable(table) 'insert/update rows by passing DataTable
db.createTable(table) 'create table from DataTable(you can drop table before create by option).

Call database function

Dim db As New DBExecution(ConnectionName)
Dim userId As Integer = 10
Dim result As String = db.executeDBFunction(Of String)("GET_USER_NAME",userId)

Entity Query

Dim users As List(Of User) = DBEntity.Read(Of User)("SELECT * FROM tab",ConnectionName)

Dim db As New DBExecution(ConnectionName)
db.addFilter("pId", 10)
Dim u As User = DBEntity.Read(Of User)("SELECT * FROM tab WHERE UserId = @pId",db).FirstOrDefault

Entity Execution

Dim user As New User(10,"Mike")
user.Save(ConnectionName)
user.Delete(ConnectionName)

About detail , Please see wiki .

databaseexecutors's People

Contributors

icoxfog417 avatar karymm avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.