Giter Site home page Giter Site logo

thunderstruck's People

Contributors

19was85 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thunderstruck's Issues

Race condition in ConnectionStringBuffer singleton

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.

Stored Procedures

Wagner, any chance you could put in stored procedure functionality? Then this library would be perfect.

Guid for Primary Key

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;
    }

SQL like does not work with parameters

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?

problem with connection string

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.

Is there a way to set directly the connection string?

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.

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.