0
为什么我的所有搜索结果都会为此workoutdate字段带来空的(默认日期时间值)?Dapper将日期时间字段作为默认值
StringBuilder query = new StringBuilder();
query.Append("SELECT W.WorkoutId, W.Active, W.GymId, W.Spots, W.UserId, W.WorkoutDate, W.WorkoutStatusId FROM [Workout] W");
public class Workout
{
public Guid WorkoutId { get; private set; }
public Guid UserId { get; set; }
public Guid? GymId { get; set; }
public int WorkoutStatusId { get; set; }
public int Spots { get; set; }
public bool Active { get; set; }
public DateTime WorkoutDate { get; set; }
}
“WorkoutDate”实际上是一个'datetime'类型的列吗?例如,如果它是一个'nvarchar',则日期时间转换可能不会成功。如果您可以向我们提供表格定义和实际的Dapper查询,将有所帮助。 – pcdev
@pcdev表定义: CREATE TABLE [DBO] [锻炼]( \t [WorkoutId] [唯一标识符] NOT NULL, \t [有效] [比特] NOT NULL, \t [GymId] [唯一标识符] NULL。 \t [斑点] [INT] NOT NULL, \t [用户ID] [唯一标识符] NOT NULL, \t [WorkoutDate] [DATETIME2](7)NOT NULL, \t [WorkoutStatusId] [INT] NOT NULL, –
和 public DateTime WorkoutDate {get; set;} –