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

  • Home
  • SEARCH
  • 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 9006643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:27:59+00:00 2026-06-16T01:27:59+00:00

I’m working on my first EntityFramework-solution, and I’m stumped. When I’m iterating through the

  • 0

I’m working on my first EntityFramework-solution, and I’m stumped.

When I’m iterating through the resulting “calendar”-entity objects, the property calendar.ref_calendar_premisis.premisis is un-instantiated (null). I understand why, I deactivated lazy-loading because i wanted to control the conditional “includes” in a syntax-tree projection like so:

    private List<CalendarBlockDTO> FillUserCalendar(DateTime start, DateTime end, int uid, bool everything)
    {
        var result = new List<CalendarBlockDTO>();

        using (var db = new ViggoEntities())
        {
            //We need to disable lazyloading to use the "expression tree" syntax
            db.Configuration.LazyLoadingEnabled = false;

            //flip our "everything" so we can compare it to our "special" column
            int specialScope = Convert.ToInt32(!everything);

            //Build a query "Projection" with "expression tree" syntax
            var query = from c in db.calendars
                        select new
                            {
                                calendarEntry = c,

                                createdByUser = c.MadeByUser,

                                premisesBookings = c.ref_calendar_premises.Where
                                (
                                    rcp => rcp.deleted == 0 &&
                                     (
                                            //started before the start-parameter AND ended after start-parameter
                                        (rcp.timestart < start && rcp.timeend > start) ||
                                            //OR startet before the end-parameter AND ended after the end-parameter
                                        (rcp.timestart < end && rcp.timeend > end) ||
                                            //OR startet before the start-parameter AND ended after the end-paremeter
                                        (rcp.timestart < start && rcp.timeend > end) ||
                                            //OR startet after the start-parameter AND ended before the end-parameter
                                        (rcp.timestart > start && rcp.timeend < end)
                                    )
                                ),

                                attendingGroups = c.ref_groups_calendar.Where
                                (
                                    rug => rug.deleted == 0
                                ),

                                groups = c.ref_groups_calendar.Select( rgc => rgc.usergroup ),

                                ////Assignments not implemented yet
                                ////assignments = c.

                                schedules = c.ref_calendar_schedule.Where
                                (
                                    sch => sch.deleted == 0
                                )
                            };

            var calEntries =
                query.ToArray().Select(c => c.calendarEntry).
                Where(
                        //If only special requested, show only special
                        c => c.special >= specialScope &&
                        //If not "MadeInInfo", show for creator as well
                        (c.madeininfo==0 && c.made_by == uid) || 
                        //Else, show to involved users
                        (c.ref_groups_calendar.Any(rgc => rgc.usergroup.ref_users_groups.Any(rug => rug.userid == uid)))
                        );

            foreach (var calendar in calEntries)
            {
                //I WANT THIS TO NOT THROW AN EXCEPTION, PREMIS SHOULD NOT BE NULL
                if (calendar.name == "Dinner with Allan" && calendar.ref_calendar_premises.Any(rcp => rcp.premis == null))
                    throw new Exception("Premis not instantiated!");

                result.AddRange(CalendarToCalendarBlockDTOs(calendar));
            }
        }

        return result;
    }

I tried adding something like:

...
room = c.ref_calendar_premises.Select(r => r.premis),
...

… But to no avail. A room has been booked for the “Dinner with Allan” event in our test data, but i cant seem to get it to load the premis-entyties.

I have no previous experience with EntityFramework, LINQ to SQL or any other ORM’s, so I might be missing something plainly obvious.

Any suggestions?

  • 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-16T01:28:01+00:00Added an answer on June 16, 2026 at 1:28 am

    I twisted the arm of our DB-responsible, and turns out premisisid is null for all rows because of a conversion error (i was looking at testdata documentation, not the actual data).
    So thanks for the input and your time, I’ll just show myself out 0_0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm making a simple page using Google Maps API 3. My first. One marker
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.