我正在開發一個Windows應用程序。我有一個模型類型的實體模型從數據庫生成。我首先導入了一些存儲過程,並且對於一個SP,我已經將上下文替換數據類型從bool更改爲int。現在,當我嘗試更新模型(添加SP)時,更改後的SP的上下文將恢復爲其默認類型,即bool導致錯誤(函數具有無效參數)。如何避免更新現有存儲過程的EntityModel.Context?
這是模型的Context.cs。在這裏,當我從布爾類型更改爲詮釋,應用程序工作正常,但是當我更新模型的類型是回到布爾和它的拋出錯誤。如何避免這種情況?
public virtual ObjectResult<Web_get_obj_details_Result> Web_get_obj_details(Nullable<byte> hcode, Nullable<byte> vcode, Nullable<byte> yearcode, Nullable<short> tranno)
{
var hcodeParameter = hcode.HasValue ?
new ObjectParameter("hcode", hcode) :
new ObjectParameter("hcode", typeof(byte));
var vcodeParameter = vcode.HasValue ?
new ObjectParameter("vcode", vcode) :
new ObjectParameter("vcode", typeof(byte));
var yearcodeParameter = yearcode.HasValue ?
new ObjectParameter("yearcode", yearcode) :
new ObjectParameter("yearcode", typeof(byte));
var trannoParameter = tranno.HasValue ?
new ObjectParameter("tranno", tranno) :
new ObjectParameter("tranno", typeof(short));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Web_get_obj_details_Result>("Web_get_obj_details", hcodeParameter, vcodeParameter, yearcodeParameter, trannoParameter);
}
我是多麼訪問SP:
IList<Web_get_obj_details_Result> ObjWeb_get_obj_details_Result = EntityObj.Web_get_obj_details(HobliCode, VillageCode, YearCode,TranNo).ToList<Web_get_obj_details_Result>();
這裏HobliCode,VillageCode,YearCode,TranNo都是int類型。
FYI:這是我的SP
ALTER PROCEDURE [dbo].[Web_get_obj_details]
@hcode as tinyint , @vcode as tinyint , @yearcode as tinyint , @tranno as smallint
as
declare @dcode as integer , @tcode as integer
begin tran
select @dcode = dist_code , @tcode = taluk_code from mst_config
select convert(varchar(10),notice_sdate,103) as notice_sdate ,convert(varchar(10),obj_date,103) as obj_date,objector_name,obj_details from tr_objection
where dist_code= @dcode and taluk_code = @tcode and hobli_code = @hcode and village_code = @vcode and tran_no [email protected] and [email protected]
commit tran
我不想改變SP的我每次更新模型的上下文。任何解決方案以及爲什麼模型將類型作爲bool提取,即使類型是int?
你的意思是'bool'或'byte'? – Sefe
@sefe抱歉..它是字節.. – Rakesh