简体   繁体   English

对NHibernate和Script#使用相同的类?

[英]Using the same classes for NHibernate and Script#?

I am about to start a project using NHibernate and Script# 我即将使用NHibernate和Script#启动一个项目

NHibernate required that all properties be virtual, so I have my entity like this: NHibernate要求所有属性都是虚拟的,因此我的实体如下所示:

public partial class User
{
    public virtual string Username { get; set; }
    public virtual string PasswordHash { get; set; }

    public virtual DateTime DateRegistered { get; set; }
}

But Script# build fails when it encountered partial and virtual . 但是Script#构建在遇到partialvirtual时失败。
Partial I can cope with but not having virtual will probably requires a redesign/thinking ahead. 我可以应付但没有虚拟的部分需求可能需要重新设计/思考。

My goal is to share code between the main models project and the front-end Script# project so I don't have to re-implement the model twice, have strong-typing support and refactoring support throughout the models and scripts etc. etc. 我的目标是在主要模型项目和前端Script#项目之间共享代码,这样我就不必两次重新实现模型,在整个模型和脚本中都具有强类型支持和重构支持,等等。

Is this possible? 这可能吗? Has anyone done this before? 有人做过吗? What are some available options? 有哪些可用选项?

我将创建一个ViewModel,并使用AutoMapper为您执行映射,然后可以将Script#与ViewModel一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM