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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:58:46+00:00 2026-05-26T22:58:46+00:00

In my method, I have this query: var query = _db.STEWARDSHIP .OrderBy(r => r.SITE.SITE_NAME)

  • 0

In my method, I have this query:

var query =
    _db.STEWARDSHIP
        .OrderBy(r => r.SITE.SITE_NAME)
        .Where(r => SiteId == null || r.SITE_ID == iSiteId)
        .Where(r => SiteTypeId == null || r.SITE.SITE_TYPE_VAL.SITE_TYPE_ID == iSiteTypeId)
        .Where(r => EcoregionId == null || r.SITE.ECOREGION_VAL.ECOREGION_ID == iEcoregionId)
        .Where(r => ConservationAreaId == null || r.SITE.CONSERVATION_AREA_VAL.CONSERVATION_AREA_ID == iConservationAreaId)
        .Where(r => VisitTypeId == null || r.VISIT_TYPE_VAL.VISIT_TYPE_ID == iVisitTypeId)
        .Where(r => Staff == null || r.STAFF.Contains(sStaff))
        .Where(r => Comment == null || r.VISIT_COMMENTS.Contains(sComment))
        .Select(r => new SiteVisitDetails
        {
            Id = r.STEWARDSHIP_ID,
            Name = r.SITE.SITE_NAME,
            VisitType = r.VISIT_TYPE_VAL.VISIT_TYPE_DESC,
            VisitDate = r.VISIT_DATE
        });

This fails with the error:

SiteVisitDetails does not contain a constructor that takes 0 arguments

Here the class:

public class SiteVisitDetails : ISiteVisitDetails
{

    private int _id;
    private string _name;
    private DateTime _visitDate;
    private string _visitType;

    public SiteVisitDetails(int Id, string Name, DateTime VisitDate, 
                            string VisitType)
    {
        _id = Id;
        _name = Name;
        _visitDate = VisitDate;
        _visitType = VisitType;
    }

    public int Id
    {
        get { return _id; }
        set { _id = value; }
    }

    public string Name
    {
        get { return _name; }
        set { _name = value; }
    }

    public DateTime VisitDate
    {
        get { return _visitDate; }
        set { _visitDate = value; }
    }

    public string VisitType
    {
        get { return _visitType; }
        set { _visitType = value; }
    }

    public string getShortVisitDate()
    { 
        return _visitDate.ToShortDateString();
    }
}

The Interface:

interface ISiteVisitDetails
{
    int Id { get; set; }
    string Name { get; set; }
    DateTime VisitDate { get; set; }
    string VisitType { get; set; }
    string getShortVisitDate;
}

I don’t understand why I would need a constructor that takes 0 arguments. Can somebody help me understand?

Thanks.

  • 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-05-26T22:58:46+00:00Added an answer on May 26, 2026 at 10:58 pm

    don’t understand why I would need a constructor that takes 0
    arguments.

    The expression:

    new SiteVisitDetails
    {
        Id = r.STEWARDSHIP_ID,
        Name = r.SITE.SITE_NAME,
        VisitType = r.VISIT_TYPE_VAL.VISIT_TYPE_DESC,             
        VisitDate = r.VISIT_DATE
    }
    

    is really shorthand for:

    new SiteVisitDetails() // Note the parantheses
    {
        Id = r.STEWARDSHIP_ID,
        Name = r.SITE.SITE_NAME,
        VisitType = r.VISIT_TYPE_VAL.VISIT_TYPE_DESC,
        VisitDate = r.VISIT_DATE
    }
    

    From the language specification:

    7.6.10.1 Object creation expressions

    […] An object creation expression can omit the constructor argument list
    and enclosing parentheses provided it includes an object initializer
    or collection initializer. Omitting the constructor argument list and
    enclosing parentheses is equivalent to specifying an empty argument
    list.

    In other words, you really are trying to call the parameterless constructor of the SiteVisitDetails type, which doesn’t exist of course.

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

Sidebar

Related Questions

in my self-defined module I have this method which will query the db and
I have this query var hql = @from Table1 tbl1 left join fetch tbl1.Table2;
I have tried inserting an orderby into this query in every conceivable spot, but
I have this linq query: private void GetReceivedInvoiceTasks(User user, List<Task> tasks) { var areaIds
i have this in my BlogRepository public IQueryable<Subnus.MVC.Data.Model.Post> GetPosts() { var query = from
I have this method which lets me translate the position of an object, animating
I have this method to display the contact numbers in my inbox: public ArrayList<String>
I have this method which leaks ~ 6KB : + (EInspectorFacilityInfo*) newWithNode: (CXMLNode*) node
I have this method (someone else wrote it!) - (CGPDFDocumentRef)getPdf { NSArray *paths =
I have this method that gets called when i press a button and removes

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.