Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have passed ids list as parameter to Store procedure but when cal storeprocedure got the error
"No mapping exists from object type System.Collections.Generic.List`1[[System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] to a known managed provider native type."


C#
var idsparam=new sqlparameter
{
  parameterName="Ids",
  value=request.ids
}
var _addressSetiingspredicate=_dbcontext.database.SqlQuery<BaseNewBusinessAdressSettingModel>(@"Exec SP_AdressSettings @Ids",idsparam).ToList<BaseNewBusinessAdressSettingModel>



Please help me
Thanks

What I have tried:

I have passed ids list as parameter to Store procedure but when cal storeprocedure got the error
"No mapping exists from object type System.Collections.Generic.List`1[[System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] to a known managed provider native type."
Posted
Updated 23-Sep-20 20:22pm
Comments
F-ES Sitecore 24-Sep-20 5:41am    
What sql type is the param for SP_AdressSettings?

1 solution

You are trying to pass a collection of integers as a single parameter value to SQL: probably from here:
C#
value=request.ids

You can't do that: SQL has no concept of arrays or Lists it only works with basic datatypes: Data types (Transact-SQL) - SQL Server | Microsoft Docs[^]

I have no idea what your SP expects to do with them, but you can't send them as a collection!
 
Share this answer
 
Comments
Krishna Veni 24-Sep-20 2:44am    
I need to pass the list of integers as parameters to sp.
OriginalGriff 24-Sep-20 3:03am    
You can't: the SP doesn't have a parameter type that takes a collection of integers - just the basic datatypes that I linked to.
You need to rethink what exactly you are doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900