locked
can not convert int to system.data.object.objecparameter RRS feed

  • Question

  • User-981858113 posted

    public static void InsertEmployee(DTOEmployee employeeDto)
    {

    Employee employeeEntity ;
    DBMetsdevEntities context = new DBMetsdevEntities();
    int vaue1=employeeDto.Employeeid;

    System.Data.Objects.ObjectParameter valu2=new System.Data.Objects.ObjectParameter("value1", typeof(int));
    // System.Data.Objects.ObjectParameter valu1=employeeDto.Employeeid;
    //int valu = new System.Data.Objects.ObjectParameter("value1", typeof(int));
    context.Sp_InsertEmployee(

    employeeEntity.Clientid=employeeDto.Clientid,
    employeeEntity.FirstName=employeeDto.FirstName,
    employeeEntity.LastName=employeeDto.LastName,
    employeeEntity.gender=employeeDto.gender,
    employeeEntity.DateofBirth=employeeDto.DateofBirth,
    employeeEntity.DateofJoining=employeeDto.DateofJoining,
    employeeEntity.Email=employeeDto.Email,
    employeeEntity.Createdby=employeeDto.Createdby,
    // new System.Data.Objects.ObjectParameter("employeeId", typeof(int))

    employeeEntity.Employeeid=valu2; //error line
    // employeeEntity.Employeeid=employeeDto.Employeeid
    );

    Sunday, December 27, 2015 8:44 AM

Answers

  • User-1716253493 posted

    Get it from value property

    employeeEntity.Employeeid = valu2.Value;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 28, 2015 2:13 AM
  • User-986267747 posted

    Hi iamdevloper91,

    employeeEntity.Employeeid=valu2; //error line

    According to your description and error message, the type of the Employeeid property is int, but the type of valu2 is  objecparameter. As oned_gk say,  you should pass the parameter value to Employeeid. Like this:

    employeeEntity.Employeeid=valu2.Value

    You could efer to the following link to get more information about objecparameter.

    https://msdn.microsoft.com/en-us/library/system.data.objects.objectparameter.value(v=vs.110).aspx

    Best Regards,

    Klein zhang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 28, 2015 5:41 AM

All replies

  • User-1716253493 posted

    Get it from value property

    employeeEntity.Employeeid = valu2.Value;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 28, 2015 2:13 AM
  • User-986267747 posted

    Hi iamdevloper91,

    employeeEntity.Employeeid=valu2; //error line

    According to your description and error message, the type of the Employeeid property is int, but the type of valu2 is  objecparameter. As oned_gk say,  you should pass the parameter value to Employeeid. Like this:

    employeeEntity.Employeeid=valu2.Value

    You could efer to the following link to get more information about objecparameter.

    https://msdn.microsoft.com/en-us/library/system.data.objects.objectparameter.value(v=vs.110).aspx

    Best Regards,

    Klein zhang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 28, 2015 5:41 AM