19was85 / thunderstruck Goto Github PK
View Code? Open in Web Editor NEWA really fast way to access databases with ADO.NET
Home Page: http://nuget.org/packages/Thunderstruck/
License: Other
A really fast way to access databases with ADO.NET
Home Page: http://nuget.org/packages/Thunderstruck/
License: Other
My code creates a context in the typical way, as follows:
using (var context = new DataContext(ConnectionStringName, Transaction.No))
{
}
However, every now and then, I get the following exception:
System.ArgumentException: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Thunderstruck.Runtime.ConnectionStringBuffer.Get(String connectionStringName)
ConnectionStringBuffer is a singleton, and it appears we're getting a race condition using a dictionary.
if (!_buffer.ContainsKey(connectionStringName))
{
_buffer.Add(connectionStringName, GetFromConfig(connectionStringName));
}
Looks like we need a lock around the _buffer.Add() call. See http://stackoverflow.com/questions/726654/what-are-the-dangers-of-using-a-singleton-in-a-multithreaded-application.
Wagner, any chance you could put in stored procedure functionality? Then this library would be perfect.
Hi
I am trying to use the DataObject to insert a row into a table that has a Guid PK. It works great with an incrementing Id. But once I switched to a Guid I can't get it to work.
I've tried setting the pk like this in the initialisation:
var userData = new DataObject("Users","Guid");
model.Guid = Guid.NewGuid();
userData.Insert(model);
But that doesn't work I get a sql error saying Guid cannot be null.
"Cannot insert the value NULL into column 'Guid', table 'Nancy.dbo.Users'; column does not allow nulls. INSERT fails."
What am I doing wrong?
Gus
ps: I found this code in DataRuntimeObject.cs which looks a bit dubious. See the "Id" bit.
public PropertyInfo GetPrimaryKey(string primaryKeyName)
{
if (_primaryKey == null)
{
var validProperties = GetValidProperties();
if (primaryKeyName != null) return validProperties.FirstOrDefault(p => p.Name == primaryKeyName);
_primaryKey = validProperties.FirstOrDefault(p => p.Name == "Id" ) ?? validProperties.First();
}
return _primaryKey;
}
I believe I have noticed a bug and it's a significant one.
In your readme you have this:
context.All("SELECT * FROM Cars WHERE Name LIKE %@0%", "Lotus");
But this causes an object ref error because there are no single quotes around the expression.
But, when I try this:
var ads = context.All("select * from myTable where Title like '%@0%'","Vis");
The parameter is ignored.
Don't supposed you can fix this?
I have the following code:
using (var context = new DataContext("SiteSQLServer",Transaction.Begin))
{
var job = new DataObject<omv_JobSeekerReferences>();
int cntr = 1;
foreach (var item in ViewState)
{
omv_JobSeekerReferences r = (omv_JobSeekerReferences) ViewState["item_" + cntr];
var newRefRow = new omv_JobSeekerReferences { UserId = r.UserId,Company = r.Company, FromDate = r.FromDate, ToDate = r.ToDate };
job.Insert(newRefRow); // add the new row to the table
cntr++;
}
}
It blows on job.Insert complaining that it can't find the connection string "Default".
Am I doing something wrong? It works fine if I add a default connection string and the row is inserted.
Hey, nice job!
currently the connection string is loaded from app/web config file, but Im wondering if there is a way to set the connection string directly to the context, if not, could be it a good improvement!.
Thanks.
We need to update the readme with few new improvements and fix some gramatical errors.
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.