Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
public IEnumerable<MemberDetails> GetallMemberlist(int pageIndex, int pageSize)
        {
            string Location = "6,3";
            string[] loc = Location.Split(',');
            DataTable dt = new DataTable();
            dt.Columns.AddRange(new DataColumn[1] { new DataColumn("CategoryID", typeof(int)) });
           
            foreach (string s in loc)
            {
                dt.Rows.Add(s);
            }
            var para = new DynamicParameters();
            para.Add("@PageIndex", pageIndex);
             para.Add("@StateIdTable", dt);
            para.Add("@PageSize", pageSize); 
            var employees = con.Query<MemberDetails>("GetCustomersPageWise", para,commandType: CommandType.StoredProcedure);
        
            return employees;
        }


and error is showing
System.NotSupportedException: 'The member StateIdTable of type System.Data.DataTable cannot be used as a parameter value'

plz help

What I have tried:

how to use dapper under 3 parameter 2 parameter normal value and one parameter  is table parameter both of using stored procedure
Posted
Updated 1-Aug-17 8:43am
Comments
Afzaal Ahmad Zeeshan 1-Aug-17 8:17am    
The error message tells clearly what is going wrong here.
vermanishad 2-Aug-17 1:32am    
yes and error is System.NotSupportedException: 'The member StateIdTable of type System.Data.DataTable cannot be used as a parameter value'

1 solution

 
Share this answer
 
Comments
vermanishad 2-Aug-17 1:34am    
when i added AsTableValuedParameter in datatable then error show datatable does not contain a definination for AsTableValuedParameter and no extension method AsTableValuedParameter
Richard Deeming 2-Aug-17 7:20am    
The extension method is declared by the SqlMapper class in the Dapper namespace:
https://github.com/StackExchange/Dapper/blob/master/Dapper/SqlMapper.cs#L3640[^]

Are you sure you're not using .NET Core instead of MVC5?

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