Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 对象类型System.collections.Generic.List中不存在映射_C#_Entity Framework_Generics_Models - Fatal编程技术网

C# 对象类型System.collections.Generic.List中不存在映射

C# 对象类型System.collections.Generic.List中不存在映射,c#,entity-framework,generics,models,C#,Entity Framework,Generics,Models,错误:发生System.ArgumentException HResult=0x80070057 Message=不存在从对象类型System.Collections.Generic.List`1[[System.object,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]]到已知托管提供程序本机类型的映射。 来源= 堆栈跟踪: 公共类PatInsuListItem:ErrorInfo { 公共

错误:发生System.ArgumentException HResult=0x80070057 Message=不存在从对象类型System.Collections.Generic.List`1[[System.object,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]]到已知托管提供程序本机类型的映射。 来源= 堆栈跟踪:

公共类PatInsuListItem:ErrorInfo
{
公共int insspan_I{get;set;}
公共int Insu_Id{get;set;}
来自{get;set;}的公共字符串Date_
公共字符串Date_To{get;set;}
公共字符串组_Name{get;set;}
公共字符串短_名称{get;set;}
公共字符串注释{get;set;}
公共字符串计划名称{get;set;}
公共字符串保险编号{get;set;}
公共字符串Touch_Date{get;set;}
公共字符串Touch_By{get;set;}
公共字符串保险RANKDESCR{get;set;}
公共字符串标志{get;set;}
公共字符串状态{get;set;}
公共int警报{get;set;}
公共字符串EndProcessIndicator{get;set;}
公共字符串LinkedAuthFlag{get;set;}
}
公共类PatEFInsuList:ErrorInfo
{
公共财政司(){
列表=新列表();
}
公开名单;
公共整数计数{get;set;}
}
var_patlist=new PatEFInsuList()

SqlParameter\u count=newsqlparameter(@count),SqlDbType.Int){Direction=System.Data.ParameterDirection.Output};
IList _paramList=新列表();
_Add(新的SqlParameter(“@patientId”,SqlDbType.Int){Value=parms.patientId});
_Add(新的SqlParameter(“@orderBy”,SqlDbType.VarChar){Value=parms.orderBy});
_Add(新的SqlParameter(“@pageSize”,SqlDbType.Int){Value=parms.pageSize});
_Add(新的SqlParameter(“@pageIndex”,SqlDbType.Int){Value=parms.pageIndex});
_Add(新的SqlParameter(“@disallowedInsu”,SqlDbType.VarChar){Value=parms.disallowedInsu});
_Add(新的SqlParameter(“@initialId”,SqlDbType.Int){Value=parms.initialId});
_Add(新的SqlParameter(“@initialCOBFlag”,SqlDbType.Bit){Value=parms.initialCOBFlag});
_paramList.Add(_count);
var_result=this.RepositoryContext.Database.SqlQuery(“exec dbo.imc_Patient_retrieveinsurancecolist@patientId、@orderBy、@pageSize、@pageIndex、@disallowedInsu、@initialId、@initialCOBFlag、@countout”、\u paramList);
_patlist.Count=\u Count.Value==null?0:(int)_count.Value;
_patlist.list=\u result.Select(t=>newpatinsulistitem
{
因苏斯潘I=t.因苏斯潘I,
因苏伊德=t.因苏伊德,
Date_From=t.Date_From,
日期至=t.日期至,
组名称=t.组名称,
Short_Name=t.Short_Name,
注=t.注,
计划名称=t.计划名称,
保险数量=t.保险数量,
触摸日期=t.触摸日期,
Touch_By=t.Touch_By,
InsuranceRankdescr=t.InsuranceRankdescr,
COBFlag=t.COBFlag,
InsStatus=t.InsStatus,
警报=t.警报,
EndProcessIndicator=t.EndProcessIndicator,
LinkedAuthFlag=t.LinkedAuthFlag
}).ToList();
返回路径列表;
运行时“ToList”行出现错误。代码编译正常。模型中有一个列表,所以我不知道为什么会发生错误。

您的问题在这里:

IList<object> _paramList = new List<object>();

可能重复的甜的可能重复。我用了你的第二个选择,我解决了这个问题。现在我的日期字段有问题了。”从物化的“System.DateTime”类型转换为“System.String”类型的指定转换无效。这是原始postyes的另一个问题。存储过程返回DateTime时,我发现我的类有字符串。这一问题已经得到解决。谢谢
        SqlParameter _count = new SqlParameter("@count", SqlDbType.Int) { Direction = System.Data.ParameterDirection.Output };

        IList<object> _paramList = new List<object>();
        _paramList.Add(new SqlParameter("@patientId", SqlDbType.Int) { Value = parms.PatientId });
        _paramList.Add(new SqlParameter("@orderBy", SqlDbType.VarChar) { Value = parms.OrderBy });
        _paramList.Add(new SqlParameter("@pageSize", SqlDbType.Int) { Value = parms.PageSize });
        _paramList.Add(new SqlParameter("@pageIndex", SqlDbType.Int) { Value = parms.PageIndex });
        _paramList.Add(new SqlParameter("@disallowedInsu", SqlDbType.VarChar) { Value = parms.DisallowedInsu });
        _paramList.Add(new SqlParameter("@initialId", SqlDbType.Int) { Value = parms.InitialId });
        _paramList.Add(new SqlParameter("@initialCOBFlag", SqlDbType.Bit) { Value = parms.InitialCOBFlag });
        _paramList.Add(_count);

        var _result = this.RepositoryContext.Database.SqlQuery<PatInsuListItem>("exec dbo.imc_Patient_RetrieveInsuranceCOBList  @patientId, @orderBy, @pageSize, @pageIndex, @disallowedInsu, @initialId, @initialCOBFlag, @count OUT", _paramList);

        _patlist.Count = _count.Value == null ? 0 : (int)_count.Value;
        _patlist.list = _result.Select(t => new PatInsuListItem
        {
            Insuspan_I = t.Insuspan_I,
            Insu_Id = t.Insu_Id,
            Date_From = t.Date_From,
            Date_To = t.Date_To,
            Group_Name = t.Group_Name,
            Short_Name = t.Short_Name,
            Note = t.Note,
            Plan_Name = t.Plan_Name,
            Insur_num = t.Insur_num,
            Touch_Date = t.Touch_Date,
            Touch_By = t.Touch_By,
            InsuranceRankdescr = t.InsuranceRankdescr,
            COBFlag = t.COBFlag,
            InsStatus = t.InsStatus,
            Alert = t.Alert,
            EndProcessIndicator = t.EndProcessIndicator,
            LinkedAuthFlag = t.LinkedAuthFlag
        }).ToList();

        return _patlist;
IList<object> _paramList = new List<object>();
    var _result = this.RepositoryContext.Database.SqlQuery<PatInsuListItem>("exec dbo.imc_Patient_RetrieveInsuranceCOBList  @patientId, @orderBy, @pageSize, @pageIndex, @disallowedInsu, @initialId, @initialCOBFlag, @count OUT", 
        new SqlParameter("@patientId", SqlDbType.Int) { Value = parms.PatientId },
        new SqlParameter("@orderBy", SqlDbType.VarChar) { Value = parms.OrderBy },
        new SqlParameter("@pageSize", SqlDbType.Int) { Value = parms.PageSize },
        new SqlParameter("@pageIndex", SqlDbType.Int) { Value = parms.PageIndex },
        new SqlParameter("@disallowedInsu", SqlDbType.VarChar) { Value = parms.DisallowedInsu },
        new SqlParameter("@initialId", SqlDbType.Int) { Value = parms.InitialId },
        new SqlParameter("@initialCOBFlag", SqlDbType.Bit) { Value = parms.InitialCOBFlag },
        new SqlParameter("@count", SqlDbType.Int) { Value = _count } //this one you attempted to pass in just the int, not a SqlParameter
    );
    var _result = this.RepositoryContext.Database.SqlQuery<PatInsuListItem>("exec dbo.imc_Patient_RetrieveInsuranceCOBList  @patientId, @orderBy, @pageSize, @pageIndex, @disallowedInsu, @initialId, @initialCOBFlag, @count OUT",
                 _paramList.ToArray());