PgSql Support datetimeoffset

This commit is contained in:
sunkaixuna 2021-12-07 19:40:56 +08:00
parent 7ab2e9ce6d
commit 79a6a72bbf
2 changed files with 11 additions and 0 deletions

View File

@ -25,6 +25,15 @@ namespace OrmTest
id2=new TimeSpan(11,2,1) id2=new TimeSpan(11,2,1)
}).ExecuteCommand(); }).ExecuteCommand();
var x= Db.Queryable<UnitTimeSpan2>().ToList(); var x= Db.Queryable<UnitTimeSpan2>().ToList();
Db.CodeFirst.InitTables<UnitDateOfTime22>();
Db.Insertable(new UnitDateOfTime22() { DateTimeOffset1 = DateTimeOffset.Now }).ExecuteCommand();
var list2 = Db.Queryable<UnitDateOfTime22>().ToList();
}
[SqlSugar.SugarTable("UnitDateOfTime221")]
public class UnitDateOfTime22
{
public DateTimeOffset DateTimeOffset1 { get; set; }
} }
public class UnitTimeSpan2 public class UnitTimeSpan2
{ {

View File

@ -28,6 +28,8 @@ namespace SqlSugar
csharpTypeName = "long"; csharpTypeName = "long";
if (csharpTypeName.ToLower().IsIn("boolean", "bool")) if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
csharpTypeName = "bool"; csharpTypeName = "bool";
if (csharpTypeName == "DateTimeOffset")
csharpTypeName = "DateTime";
var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList(); var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList();
if (mappings!=null&&mappings.Count>0) if (mappings!=null&&mappings.Count>0)
return mappings.First().Key; return mappings.First().Key;