将 DateTime 属性映射到时间戳 mysq+fluentnhibernate
我在使用 fluidNhibernate 和 MySQL 时遇到了一些问题。 我想将我的实体映射
public class Topic
{
public Topic()
{
ParentTopic = null;
}
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual DateTime CreatedAt { get; private set; }
public virtual Guid CreatedBy { get; set; }
public virtual IList<Post> Posts { get; set; }
public virtual Topic ParentTopic { get; set; }
}
到具有相同名称的表。我最大的问题是如何进行 CreatedAt 的映射,以便在数据库中获得一个仅在插入时更改并在更新时忽略的时间戳。
谢谢 ;)
I have a little problem with fluentNhibernate and MySQL.
I would like to map my entity:
public class Topic
{
public Topic()
{
ParentTopic = null;
}
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual DateTime CreatedAt { get; private set; }
public virtual Guid CreatedBy { get; set; }
public virtual IList<Post> Posts { get; set; }
public virtual Topic ParentTopic { get; set; }
}
To a table with the same name. My bigest problem is how to I do the mapping of the CreatedAt
so that in the database I get a timestamp that is only changed on insert and ignored when updating.
thx ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了我的小问题的答案:)
这在我的单元测试中似乎有效。希望以后不会产生更大的问题。
如果有人对此有疑问,请告诉我。
Found the answer to my little problem :)
This seams to work in my unit tests. Hope that it will not produce any greater problems in the future.
If anybody seas a problem with this then please let me know.