mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
PgSql support timespan
This commit is contained in:
parent
29935a3fbd
commit
8dc59daf3b
@ -18,8 +18,20 @@ namespace OrmTest
|
|||||||
Db.DbMaintenance.TruncateTable<UnitCodeTest22>();
|
Db.DbMaintenance.TruncateTable<UnitCodeTest22>();
|
||||||
Db.CodeFirst.InitTables<UnitCodeTest3>();
|
Db.CodeFirst.InitTables<UnitCodeTest3>();
|
||||||
Db.Insertable(new UnitCodeTest22() { id=1}).ExecuteCommand();
|
Db.Insertable(new UnitCodeTest22() { id=1}).ExecuteCommand();
|
||||||
|
Db.CodeFirst.InitTables<UnitTimeSpan2>();
|
||||||
|
Db.Insertable(new UnitTimeSpan2()
|
||||||
|
{
|
||||||
|
Id=new TimeSpan(),
|
||||||
|
id2=new TimeSpan(11,2,1)
|
||||||
|
}).ExecuteCommand();
|
||||||
|
var x= Db.Queryable<UnitTimeSpan2>().ToList();
|
||||||
|
}
|
||||||
|
public class UnitTimeSpan2
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType ="time")]
|
||||||
|
public TimeSpan Id { get; set; }
|
||||||
|
public TimeSpan id2 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UnitCodeTest22 {
|
public class UnitCodeTest22 {
|
||||||
[SqlSugar.SugarColumn(IsNullable =true)]
|
[SqlSugar.SugarColumn(IsNullable =true)]
|
||||||
public decimal? id { get; set; }
|
public decimal? id { get; set; }
|
||||||
|
@ -24,6 +24,19 @@ namespace OrmTest
|
|||||||
Db.CodeFirst.InitTables<UnitCodeFirstpks3>();
|
Db.CodeFirst.InitTables<UnitCodeFirstpks3>();
|
||||||
Db.CodeFirst.InitTables<UnitCodeFirstpks32>();
|
Db.CodeFirst.InitTables<UnitCodeFirstpks32>();
|
||||||
db.CodeFirst.InitTables<UnitTest0122132>();
|
db.CodeFirst.InitTables<UnitTest0122132>();
|
||||||
|
Db.CodeFirst.InitTables<UnitTimeSpan2>();
|
||||||
|
Db.Insertable(new UnitTimeSpan2()
|
||||||
|
{
|
||||||
|
Id = new TimeSpan(),
|
||||||
|
id2 = new TimeSpan(11, 2, 1)
|
||||||
|
}).ExecuteCommand();
|
||||||
|
var x = Db.Queryable<UnitTimeSpan2>().ToList();
|
||||||
|
}
|
||||||
|
public class UnitTimeSpan2
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType = "time")]
|
||||||
|
public TimeSpan Id { get; set; }
|
||||||
|
public TimeSpan id2 { get; set; }
|
||||||
}
|
}
|
||||||
public class UnitTest0122132
|
public class UnitTest0122132
|
||||||
{
|
{
|
||||||
|
@ -126,8 +126,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (type == UtilConstants.TimeSpanType)
|
else if (type == UtilConstants.TimeSpanType)
|
||||||
{
|
{
|
||||||
if (this.Value != null)
|
this.DbType = System.Data.DbType.Time;
|
||||||
this.Value = this.Value.ToString();
|
|
||||||
}
|
}
|
||||||
else if (type!=null&&type.IsEnum())
|
else if (type!=null&&type.IsEnum())
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ namespace SqlSugar
|
|||||||
new KeyValuePair<string, CSharpDataType>("bit",CSharpDataType.byteArray),
|
new KeyValuePair<string, CSharpDataType>("bit",CSharpDataType.byteArray),
|
||||||
new KeyValuePair<string, CSharpDataType>("bit varying",CSharpDataType.byteArray),
|
new KeyValuePair<string, CSharpDataType>("bit varying",CSharpDataType.byteArray),
|
||||||
new KeyValuePair<string, CSharpDataType>("varbit",CSharpDataType.@byte),
|
new KeyValuePair<string, CSharpDataType>("varbit",CSharpDataType.@byte),
|
||||||
|
new KeyValuePair<string, CSharpDataType>("time",CSharpDataType.TimeSpan),
|
||||||
};
|
};
|
||||||
public override List<string> StringThrow
|
public override List<string> StringThrow
|
||||||
{
|
{
|
||||||
|
@ -130,6 +130,12 @@ namespace SqlSugar
|
|||||||
sqlParameter.Size = parameter.Size;
|
sqlParameter.Size = parameter.Size;
|
||||||
sqlParameter.Value = parameter.Value;
|
sqlParameter.Value = parameter.Value;
|
||||||
sqlParameter.DbType = parameter.DbType;
|
sqlParameter.DbType = parameter.DbType;
|
||||||
|
var isTime = parameter.DbType == System.Data.DbType.Time;
|
||||||
|
if (isTime)
|
||||||
|
{
|
||||||
|
sqlParameter.SqlDbType = SqlDbType.Time;
|
||||||
|
sqlParameter.Value=DateTime.Parse(parameter.Value?.ToString()).TimeOfDay;
|
||||||
|
}
|
||||||
if (sqlParameter.Value!=null&& sqlParameter.Value != DBNull.Value && sqlParameter.DbType == System.Data.DbType.DateTime)
|
if (sqlParameter.Value!=null&& sqlParameter.Value != DBNull.Value && sqlParameter.DbType == System.Data.DbType.DateTime)
|
||||||
{
|
{
|
||||||
var date = Convert.ToDateTime(sqlParameter.Value);
|
var date = Convert.ToDateTime(sqlParameter.Value);
|
||||||
|
Loading…
Reference in New Issue
Block a user