我有Timestamp字段类型VARBINARY我想问一下我应该如何使用代码首先在Timestamp字段上插入byte []
private void AddDataToFormsTable(AthenaContext context)
{
List<Form> listOfForms = new List<Form>( )
{
new Form(){ UniqeId = Guid.NewGuid(), Name = "Form", Description = "form", ModifiedBy = " ",ModifiedOn = DateTime.Now,CreatedBy = " ",CreatedOn = DateTime.Now},
new Form(){ UniqeId = Guid.NewGuid(), Name = "Form2", Description = "form2", ModifiedBy = " ",ModifiedOn = DateTime.Now,CreatedBy = " ",CreatedOn = DateTime.Now},
new Form(){ UniqeId = Guid.NewGuid(), Name = "Form3", Description = "form3", ModifiedBy = " ",ModifiedOn = DateTime.Now,CreatedBy = " ",CreatedOn = DateTime.Now},
new Form(){ UniqeId = Guid.NewGuid(), Name = "Form4", Description = "form4", ModifiedBy = " ",ModifiedOn = DateTime.Now,CreatedBy = " ",CreatedOn = DateTime.Now},
new Form(){ UniqeId = Guid.NewGuid(), Name = "Form5", Description = "form5", ModifiedBy = " ",ModifiedOn = DateTime.Now,CreatedBy = " ",CreatedOn = DateTime.Now},
};
listOfForms.ForEach(i =>context.Forms.Add(i));
context.SaveChanges();
}
答案 0 :(得分:0)
轻松解决方案,将CreatedOn的类型更改为数据库中的DateTime,
否则:Convert.ToByte(DateTime.Now)