deepumi / data.net Goto Github PK
View Code? Open in Web Editor NEWA simple, light weight data access library for any ADO.Net providers like SQL server,Oracle & MySQL.
License: MIT License
A simple, light weight data access library for any ADO.Net providers like SQL server,Oracle & MySQL.
License: MIT License
DataParameters class will accept a length parameter which is useful when you have 5+ parameters creation, since DataParameters class is backed by List<T> class which will be allocated unnecessary arrays. And adding length constructor we can prevent this behavior and allocate how much we required in upfront.
private const int DefaultCapacity = 4;
public DataParameters() : this(DefaultCapacity) { }
public DataParameters(int capacity)
{
if (capacity <= 0) capacity = DefaultCapacity;
_parameters = new List<object>(capacity);
}
Add following async apis
public async Task<int> ExecuteNonQueryAsync(string sql, CommandType commandType = CommandType.Text, DataParameters parameters = null, CancellationToken token = default(CancellationToken));
public async Task<T> ExecuteScalarAsync<T>(string sql, CommandType commandType = CommandType.Text, DataParameters parameters = null, CancellationToken token = default(CancellationToken));
public async Task<IDataReader> ExecuteReaderAsync(string sql, CommandType commandType = CommandType.Text,
DataParameters parameters = null, CommandBehavior behavior = CommandBehavior.CloseConnection, CancellationToken token = default(CancellationToken));
public async Task<T> QuerySingleAsync<T>(string sql, CommandType commandType = CommandType.Text, DataParameters parameters = null,
CommandBehavior behavior = CommandBehavior.CloseConnection, CancellationToken token = default(CancellationToken));
Following methods are no longer supported starting from Data.Net 2.0.0+
Instead use the below alternatives.
public Database(IDbConnection connection, bool useTransaction)
public Database(IDbConnection connection, bool useTransaction, IsolationLevel isolationLevel)
public class Location
{
public string Area { get; set; }
}
using (var db = new Database(new OracleConnection("connecitonString" )))
{
try
{
var x = db.Query<Location>("SELECT 'test' as Area FROM Dual");
}
catch (Exception e)
{
}
}
at Data.Net.DataRowReader.ReaderToType[T](IDataReader reader) in C:\Projects\Data.Net\Data.Net\DataRowReader.cs:line 32
at Data.Net.Database.Query[T](String sql, CommandType commandType, DataParameters parameters, CommandBehavior behavior) in C:\Projects\Data.Net\Data.Net\Database.cs:line 127
at Data.Net.Oracle.Test.Program.Main(String[] args) in C:\Projects\Data.Net\Data.Net.Oracle.Test\Program.cs:line 16
Based on the recent announcement here https://devblogs.microsoft.com/dotnet/announcing-the-net-framework-4-8/ Data.Net library will support .Net Framework 4.8
Following line throws exception
[TestMethod]
public void Query_Single_String()
{
var q = _db.QuerySingle<string>("SELECT FirstName From Users_Test");
Assert.IsTrue(q != null);
}
Stack trace
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance[T]()
at Data.Net.DataRowReader.ReaderToType[T](IDataReader reader) in DataRowReader.cs:line 24
at Data.Net.Database.QuerySingle[T](String sql, CommandType commandType, DataParameters parameters, CommandBehavior behavior) in Database.cs:line 158
at Data.Net.MsSql.Test.QueryTest.Query_Single_String()
To
var p = cmd.CreateParameter();
p.ParameterName = parameter.Name;
p.Value = parameter.Value ?? System.DBNull.Value;
From
var p = cmd.CreateParameter();
p.ParameterName = parameter.Name;
p.Value = parameter.Value;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.