SubSonic 3.0 Simple Repository Adding a DateTime Property To An Object
Posted
by Blounty
on Stack Overflow
See other posts from Stack Overflow
or by Blounty
Published on 2009-09-08T12:56:44Z
Indexed on
2010/03/19
12:51 UTC
Read the original article
Hit count: 368
I am trying out SubSonic to see if it is viable to use on production projects. I seem to have stumbled upon an issue whith regards to updating the database with default values (String and DateTime) when a new column is created.
If a new property of DateTime or String is added to an object.
public class Bug
{
public int BugId { get; set; }
public string Title { get; set; }
public string Overview { get; set; }
public DateTime TrackedDate { get; set; }
public DateTime RemovedDate { get; set; }
}
When the code to add that type of object to the database is run
var repository = new SimpleRepository(SimpleRepositoryOptions.RunMigrations);
repository.Add(new Bug()
{
Title = "A Bug",
Overview = "An Overview",
TrackedDate = DateTime.Now
});
it creates the following sql:
UPDATE Bugs SET RemovedDate=''01/01/1900 00:00:00''
For some reason it is adding double 2 single quotes to each end of the string or DateTime.
This is causing the following error:
System.Data.SqlClient.SqlException - Incorrect syntax near '01'
I am connecting to SQL Server 2005
Any help would be appreicated as apart from this issue i am finding SubSonic to be a great product.
I have created a screen cast of my error here:
© Stack Overflow or respective owner