是的,还有另一个nhibernate&存储过程问题,对不起......
我有两个存储过程返回相同的结构(所以我想将它们绑定到同一个类),唯一的区别是第二个存储过程中的'where'条件。我可以将两个存储过程绑定到我的类吗?映射文件如何?或者您更喜欢不同的方法:
第一个存储过程:
ALTER procedure [BadCodes].[GetCodesBetween]
@codeFrom bigint,
@codeTo bigint
as
begin
set nocount on
;with BadCodesOriginal as (
select Code
from Scanning.BadCodes
where Code between @codeFrom and @codeTo
),
BadCodesScanned as (
select Code, count(*) NumberOfBadCodesScanned
from BadCodes.Scan
where Code between @codeFrom and @codeTo
group by Code
)
select t1.Code Code, isnull(t2.NumberOfBadCodesScanned, 0) NumberOfBadCodesScanned
from BadCodesOriginal t1 left join BadCodesScanned t2 on (t1.Code = t2.Code)
order by t1.Code
end
第二个存储过程:
ALTER procedure [BadCodes].[GetCodesBetweenDifference]
@codeFrom bigint,
@codeTo bigint
as
begin
set nocount on
;with BadCodesOriginal as (
select Code
from Scanning.BadCodes
where Code between @codeFrom and @codeTo
),
BadCodesScanned as (
select Code, count(*) NumberOfBadCodesScanned
from BadCodes.Scan
where Code between @codeFrom and @codeTo
group by Code
)
select t1.Code Code, isnull(t2.NumberOfBadCodesScanned, 0) NumberOfBadCodesScanned
from BadCodesOriginal t1 left join BadCodesScanned t2 on (t1.Code = t2.Code)
where isnull(t2.NumberOfBadCodesScanned, 0) <> 1
order by t1.Code
end
这是我的班级:
public class CheckedBadCodeOverview
{
public virtual long Number { get; set; }
public virtual int NumberOfScans { get; set; }
public CheckedBadCodeOverview()
{
}
}