TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aseem Bhardwaj
1.6k
114
20.3k
Mapping of classes and sub classes by fluent NHibernate
May 21 2018 12:16 AM
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 (CtasTutes):-
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
; }
}
}
}
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
; }
}
}
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)"
);
DynamicUpdate();
}
}
}
Reply
Answers (
0
)
Double back slashes inserted on receiving JSON(HttpClient)
How to assign separate CSS file for pages in ASP.NET