出力パラメータを持つ以下のストアド プロシージャがあります。
ALTER proc [dbo].[CRS_GetNewMessageCount]
@CaseId int,
@Type varchar(50),
@Location varchar(50),
@Count int out
as
begin
if @location='admin'
begin
if @type='consumer'
select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsConsumerType=1 and fdIsReadatAdmin=0)
else
select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsMemberType=1 and fdIsReadatAdmin=0)
end
else
begin
if @type='consumer'
select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsConsumerType=1 and fdIsReadatFront=0)
else
select @Count=(Select count(fdId) from tb_CRS_Messages where fdCaseId=@CaseId and fdIsMemberType=1 and fdIsReadatFront=0)
END
SELECT @Count
END
SQL サーバーでの作業は完璧です。以下の出力を参照してください。
私はこれstored procedure
を呼び出していますEntity Framework
:
using (DbContext db = new DbContext())
{
try
{
var NewMessage = new ObjectParameter("Count", typeof(int));
int returnValue = 0;
db.CRS_GetNewMessageCount(CaseId, type, location, NewMessage);
int.TryParse(NewMessage.Value.ToString(), out returnValue);
return returnValue;
}
catch { return 0; }
}
null
出力パラメータに値を与えます。
助けてください。