Bug 49004 - Mono and storing Timespan in sql server
Summary: Mono and storing Timespan in sql server
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 4.8.0 (C9)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-12-05 12:16 UTC by Simeon
Modified: 2016-12-05 13:16 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Simeon 2016-12-05 12:16:56 UTC
Hi
I am trying to run my .Net MVC project on Mac OS X. I am trying to store a model with Timespan property in sql server 2008 database.But I am keep getting an error, when code is trying to store a value in timespan property.

"The parameter data type of System.TimeSpan is invalid."

I ran same project in windows ,connecting to same sql server and it works just fine.

Trying to debug the issue, I created a simple MVC project via xamarim studio. It uses entity framework code first approach and has one class:

	public class User
	{
		public User()
		{
		}
		public int Id { get; set; }
		public string Name { get; set; }
		public TimeSpan? TheTime { get; set; }
	}

In the home controller, I am doing that:

	                var db = new SchoolContext();
			db.Database.Delete();
			db.Database.Create();
			var user = new User();
			user.Name = "aaaa";
			//user.TheTime = new TimeSpan(1,2,3);
			db.Users.Add(user);
			db.SaveChanges();

The code runs fine unless I am uncomment the line with with "user.TheTime".
Also, the code runs fine in windows. Usual operations with the timespan are OK.



Here is full error - http://pastebin.com/0Y3eC5Tc
Comment 1 Simeon 2016-12-05 13:13:01 UTC
I examined the source code of System.Data.SqlClient.SqlParameter. I can't see any mentioning of Timespan type.
So, I added [Column(TypeName = "time")] to the class  User.TheTime property, but code throws same error in InferSqlType method.

Note You need to log in before you can comment on or make changes to this bug.