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


this 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 im using list products sql database, each product have link details page show more informations it

what im trying put product label in link let show www.mysite.com\products\battery (not id)

i've imagined should work, throw the data types text , nvarchar incompatible in equal operator. error , neither (pr => pr.product1.equals(id)); works

the error clear , im asking how should make work way ?

thanks

text columns in sql server considered large object data , therefore aren't indexable/searchable. they're deprecated. so, actually, problem in database, not in application.

if change column type varchar(max), can store same amount of character data shouldn't have problem. then, update linq sql entity, , you'll no longer particular error.

having said that... column named id shouldn't text or varchar(max), should auto-increment integer id or guid (uniqueidentifier), might want revisit db design. assuming have reasons ids string values of arbitrary size, above change allow filter on column.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -