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 8381893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:47:52+00:00 2026-06-09T16:47:52+00:00

I use EntityFramework, I’m querying and returning partial data using Anonymous Types. Currently I’m

  • 0

I use EntityFramework, I’m querying and returning partial data using Anonymous Types. Currently I’m using IQueryable<dynamic>, it works, but I would like to know if this is the proper way to do it or if there is some other returning datatype that I’m not aware of.

public IQueryable<dynamic> FindUpcomingEventsCustom(int daysFuture)
{
    DateTime dateTimeNow = DateTime.UtcNow;
    DateTime dateTimeFuture = dateTimeNow.AddDays(daysFuture);
    return db.EventCustoms.Where(x => x.DataTimeStart > dateTimeNow & x.DataTimeStart <= dateTimeFuture)
        .Select(y => new { y.EventId, y.EventTitle, y.DataTimeStart});
}
  • 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-09T16:47:54+00:00Added an answer on June 9, 2026 at 4:47 pm

    Normally, you use anonymous types only inside the scope of one method. You don’t return anonymous types to the caller. If that’s what you want to do, you should create a class and return that:

    public class Event
    {
        private readonly int _eventId;
        private readonly string _eventTitle;
        private readonly DateTime _dateTimeStart;
    
        public Event(int eventId, string eventTitle, DateTime dateTimeStart)
        {
            _eventId = eventId;
            _eventTitle = eventTitle;
            _dateTimeStart = dateTimeStart;
        }
    
        public int EventId { get { return _eventId; } }
        public string EventTitle { get { return _eventTitle; } }
        public DateTime DateTimeStart{ get { return _dateTimeStart; } }
    }
    
    
    
    public IQueryable<Event> FindUpcomingEventsCustom(int daysFuture) 
    { 
        DateTime dateTimeNow = DateTime.UtcNow; 
        DateTime dateTimeFuture = dateTimeNow.AddDays(daysFuture); 
        return db.EventCustoms
                 .Where(x => x.DataTimeStart > dateTimeNow
                             && x.DataTimeStart <= dateTimeFuture) 
                 .Select(y => new Event(y.EventId, y.EventTitle, y.DataTimeStart)); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use EntityFramework to work with MySQL database from c#. I'm using
I'm using EntityFramework for data access and wpf as UI. If I bind WPF
As I understand it, Crystal Reports can use EntityFramework, is the correct? I'd rather
I have a WCF service that processes some messages. I use EntityFramework to retrieve
I use Entity Framework 4.0. Is it possible that SaveChanges() returns 0 but doesn't
In a silverlight applicaiton i use entity framework as Data Access Layer. I want
For my ASP.NET MVC 2 application I use Entity Framework 1.0 as my data
I use EntityFramework CodeFirst MVC3. In my model I defined a nullable property like
Is there a way to use EntityFramework 4.3 beta with migrations with MySql database?
Im using EntityFramework and EntityFramework.Migrations to implement solution using Code-First and Automatic Migrations. Wherever

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.