通过流畅的nhibernate映射类和子类

通过流畅的nhibernate映射类和子类

本文介绍了通过流畅的nhibernate映射类和子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,



我在映射模型类时遇到问题(带子类)。

我没有得到名字。它在编写代码时显示错误。

错误是CatsTute不包含'Name'的定义,并且没有扩展方法'Name'可以找到接受'CatsTute'类型的第一个参数(你是否缺少using指令或汇编参考?):

这是主模型(CatsTutes):

hi friends,

I am getting problem while mapping my model class(with subclasses).
I am not getting the Name. It shows error while writing the code.
The error is "CatsTute' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'CatsTute' could be found (are you missing a using directive or an assembly reference?)":
Here is main model (CatsTutes):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using codes.Models.BaseModel;

namespace codes.Models
{
    public class CatsTute:ModelBase
    {
        public class Category:ModelBase
        {
            public virtual string Name { get; set; }
            public virtual string Image { get; set; }
        }
        public class SubCat:ModelBase
        {
            public virtual int CatId { get; set; }
            public virtual string Name { get; set; }
            public virtual string Image { get; set; }
        }
        public class Tutorial:ModelBase
        {
            public virtual string Name { get; set; }
            public virtual string Description { get; set; }
            public virtual int SubCatId { get; set; }
        }
    }
}



这是基本型号(ModelBase): -


This is base model(ModelBase):-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace codes.Models.BaseModel
{
    public class ModelBase
    {
        public virtual int Id { get; set; }
        public virtual DateTime CreatedOn { get; set; }
        public virtual DateTime UpdatedOn { get; set; }
        public virtual int Deleted { get; set; }
        public virtual bool Status { get; set; }
    }
}



这是映射类(AllMapping): -


Here is mapping class(AllMapping):-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FluentNHibernate.Mapping;

namespace codes.Models.Mapping
{
    public class AllMappings : ClassMap<CatsTute>
    {
        public AllMappings()
        {
            Table("CatsTute");
            Id(x => x.Id, "Id").GeneratedBy.Identity().UnsavedValue(0);
            Map(x => x.Status);
            Map(x => x.CreatedOn);
            Map(x => x.UpdatedOn);
            Map(x => x.Deleted);
            Map(x => x.Name).CustomSqlType("nvarchar(50)");   <========Here is the problem
            DynamicUpdate();
        }
    }
}





我尝试了什么:



我不知道该怎么做............



What I have tried:

I don't know what to do............

推荐答案


这篇关于通过流畅的nhibernate映射类和子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 01:52