Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:46:39+00:00 2026-06-17T19:46:39+00:00

These are my classes: public class HotelRoomRatingView { public int HotelID { get; set;

  • 0

These are my classes:

public class HotelRoomRatingView
    {
        public int HotelID { get; set; }
        public roomKinds RoomKinds { get; set; }
        public HotelReview HotelReview { get; set; }

        public HotelRoomRatingView()
        {
        }
        public HotelRoomRatingView(int hotelId, roomKinds rooms, HotelReview review)
        {
            this.HotelID = hotelId;
            this.RoomKinds = rooms;
            this.HotelReview = review;
        }
    }

public class HotelReview
{
    public int HotelReviewID { get; set; }

    public double Rating { get; set; }

    public List<Review> Reviews { get; set; }

    public HotelReview()
    {
        this.Reviews = new List<Review>();
    }
}

public partial class roomKinds : object, System.ComponentModel.INotifyPropertyChanged
{
    [Key]
    public int roomKindsId { get; set; }

    private ObservableCollection<objectKind> objectKindField;

    public roomKinds()
    {

    }
    public roomKinds(Class.roomKinds origin)
    {
        this.objectKindField = origin.objectKind;
    }

    [System.Xml.Serialization.XmlElementAttribute(Order = 0)]
    public ObservableCollection<objectKind> objectKind
    {
        get
        {
            return this.objectKindField;
        }
        set
        {
            this.objectKindField = value;
            this.RaisePropertyChanged("objectKind");
        }
    }

    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged(string propertyName)
    {
        System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
        if ((propertyChanged != null))
        {
            propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}
public partial class Hotel : object, System.ComponentModel.INotifyPropertyChanged
    {
        [Key]
        public int HotelId { get; set; }
        private int hotIdField;
        // many others properties
        [System.Xml.Serialization.XmlElementAttribute(Order = 105)]
        public HotelReview hotelReview
        {
            get;
            set;
        }

        [System.Xml.Serialization.XmlElementAttribute(Order = 104)]
        public roomKinds rooms
        {
            get;
            set;
        }

        [System.Xml.Serialization.XmlElementAttribute(Order = 0)]
        public int hotId
        {
            get
            {
                return this.hotIdField;
            }
            set
            {
                this.hotIdField = value;
                this.RaisePropertyChanged("hotId");
            }
        }
    }

Get method in my repository looks like this:

public Models.Hotel Get(int id)
        {
            return db.hotels.SingleOrDefault(h => h.hotId == id);
        }

HotelId and hotId are okay I need it this way. So I am getting Hotel from database by LINQ and I get Hotel but I am not getting data from other tables. I am not getting HotelReview and RoomKinds. I got null in these properties but in database they are and they are connected with Hotel by ID.
Thanks for help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:46:41+00:00Added an answer on June 17, 2026 at 7:46 pm

    You will need to load those explicitly by using .Include:

    return db.hotels.Include(hr => hr.HotelReview)
                    .Include(rk => rk.RoomKinds)
                    .SingleOrDefault(h => h.hotId == id);
    

    UPDATE

    Assuming your entities are linked up properly, you should be able to just continue down the chain in your .Include:

    return db.hotels.Include(hr => hr.HotelReview)
                    .Include(r => r.HotelReview.Reviews)
                    .Include(rk => rk.RoomKinds)
                    .SingleOrDefault(h => h.hotId == id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider these classes: public class BaseClass { public int SomeInt { get; set; }
I have these classes: public class Project { public int ProjectId { get; set;
I have these classes: public class Person { public int Id{ get; set ;}
I have two classes: public class TestClass1 { public int TestInt { get; set;
I have these 3 classes: public class Product { public int ProductId { get;
I have these classes: public class RegionResult { public string Region { get; set;
I have these classes: public class MovieExt { public string Title { get; set;
Let's say we have these two classes: public class Base { public static int
This is easier to explain with an example. Given these two classes: public class
I have this classes: public class User { [Key] public Guid UserId { get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.