gpt4 book ai didi

c# - “对象”不包含采用 0 个参数的构造函数

转载 作者:行者123 更新时间:2023-11-30 13:20:25 32 4
gpt4 key购买 nike

<分区>

在我的方法中,我有这个查询:

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
});

失败并出现错误:

SiteVisitDetails 不包含采用 0 个参数的构造函数

这里是类:

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();
}
}

界面:

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

我不明白为什么我需要一个接受 0 个参数的构造函数。有人可以帮我理解吗?

谢谢。

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com