The data types text and nvarchar are incompatible in the equal to operator

Posted by metro on Stack Overflow See other posts from Stack Overflow or by metro
Published on 2010-04-28T03:33:33Z Indexed on 2010/04/28 3:43 UTC
Read the original article Hit count: 260

Hi there. this is my code

ProductController.cs

public ActionResult Details(string id)
{
    product productx = productDB.products.Single(pr => pr.Product1 == id);
    return View(productx);


}

Details.aspx

    <td>
        <%-- : Html.ActionLink("Edit", "Edit", new { id=item.Id }) % --> 
        <%: Html.ActionLink("Details", "Details", new { id = item.Product1 })%>
    </td>

this is what im using to list some products from a sql database, each product have a link to a Details page to show more informations about it

what Im trying is to only put the product label in that link to let it show something like www.mysite.com\products\battery (not the id)

I've imagined this should work, but it throw an The data types text and nvarchar are incompatible in the equal to operator. error and neither (pr => pr.Product1.Equals(id)); works

the error is clear and Im asking how should I do to make it work this way ?

thanks

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about c#