利用存储过程进行查询,仅查询了部分字段(声明:查询所有字段时正常),出现如下错误,请求高人指教,先行谢过了。
报错:数据读取器与指定的“DRCNet.DMS.CMS.Model.Customers”不兼容。某个类型为“CustomerID”的成员在同名的数据读取器中没有对应的列。
报错指示代码:return base.ExecuteFunction<Customers>("PR_SearchCustomer", operatingSystemIDParameter, databaseIDParameter, pastUserParameter);
问题补充:
存储过程:
CREATE PROCEDURE [dbo].[PR_CustomerSearch]
@AreaID int,
@IndustryID int,
@ContractNo nvarchar(128),
@CustomerName nvarchar(128),
@CustomerTypeID int,
@UpdateWayID int,
@OperatingSystemID int,
@DatabaseID int,
@PastUser int
AS
select CustomerName,
(select UpdateWayName from dbo.UpdateWay Where (dbo.Customers.UpdateWayID=UpdateWayID)) AS UpdateWayName,
ContractStartDate,ContractEndDate,
(select ContactRecord=ContactName+';'+ContactPhone+';'+ContactPhone from dbo.Contacts Where (dbo.Customers.CustomerID=CustomerID) and (ContactTypeID=1)) AS ContactRecord,
LastUpdatedDate
from Customers
where
(@AreaID=0 or AreaID=@AreaID)
and
(@IndustryID=0 or IndustryID=@IndustryID)
and
(@ContractNo='' or ContractNo like '%' +@ContractNo + '%' )
and
(@CustomerName='' or CustomerName like '%' +@CustomerName+'%')
and
(@CustomerTypeID=0 or CustomerTypeID=@CustomerTypeID)
and
(@UpdateWayID=0 or UpdateWayID=@UpdateWayID)
and
(@OperatingSystemID=0 or OperatingSystemID=@OperatingSystemID)
and
(@DatabaseID=0 or DatabaseID=@DatabaseID)
--and
--(@RecordStatus=0 or RecordStatus=@RecordStatus)
--and
--(@Sales='' or Sales like '%'+@Sales+'%')
and
(
@PastUser =0 or
(
(@PastUser=1 and ContractEndDate<getdate())
or
(@PastUser=2 and ContractEndDate>=getdate())
)
)
GO