Skip to content

System.Xml.Linq.XElement cannot be used as a parameter value at Dapper #427

@dalvirsaini

Description

@dalvirsaini

I am using dapper dot net for making Db calls.

now one of my sp having input parameter as Db type XML

Now i am executing sp like

var param = new DynamicParameters();
param.Add("@TagXML", string.IsNullOrEmpty(student.TagXML)?null:XElement.Parse(student.TagXML));
param.Add("@CustomTagXML", string.IsNullOrEmpty(student.CustomTagXML) ? null : XElement.Parse(student.CustomTagXML));
param.Add("@Return", strRet, direction: ParameterDirection.Output);
param.Add("@RetunErrMsg", strRetMsg, direction: ParameterDirection.Output);
using (var connection = new SqlConnection(ConnectionString))
{
    if (connection.State != ConnectionState.Open)
    {
        connection.Open();
    }
    connection.Execute("My Sp here", param, commandType: CommandType.StoredProcedure);
}

This code giving me error:

System.NotSupportedException: The member TagXML of type System.Xml.Linq.XElement cannot be used as a parameter value
   at Dapper.SqlMapper.LookupDbType(Type type, String name, Boolean demand, ITypeHandler& handler)

Why this error coming? How I can use XML type of inputs in StoredProcedure.?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions