简体   繁体   中英

Using the same classes for NHibernate and Script#?

I am about to start a project using NHibernate and Script#

NHibernate required that all properties be virtual, so I have my entity like this:

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 .
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.

Is this possible? Has anyone done this before? What are some available options?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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