score:7
text
columns do not support the equal to operator, even in sql.
you must make it so your query translates into a like
operator, which can be achieved with either contains
(like '%str%'
), startswith
(like '%str'
) or endswith
(like '%str'
).
if you need strict equality, something like this should work:
var result = db.table.where(x => x.columna.startswith("a") &&
x.columna.endswith("a")).tolist();
score:0
i had the same issue and none of the string conversion solutions worked for me.
the problem was that i had a 'text'
data type for this column (because i migrated it from sqlite).
solution: just change the data type to `'nvarchar()' and regenerate the table.
score:1
i tried all the above-mentioned solution and none of the fixes works for me, so here i am posting the fix which works for me
var result = db.table.where(x => convert.tostring(x.columna) == "a").tolist();
score:2
can you cast the column in question to a string? i haven't got any way to test this as i don't have a db with a text
type.
var result = db.table.where(x => x.columna.tostring() == "a").tolist();
score:3
you can use this (i haven't tested the code)
var result = db.table.where(x => x.columna.contains("a")).tolist();
Source: stackoverflow.com
Related Query
- LINQ compare string and DB column type 'text'
- linq join on guid and string column
- Linq Order by when column name is dynamic and pass as a string to a function
- Split each two-word string in a list, compare if same and count using Linq
- The given value of type String from the data source cannot be converted to type int of the specified target column
- Convert string to long type and use in a linq query within asp.net MVC
- Compare int and string with leading zeros with LINQ and SQLServer
- How to compare a string column to a number (as a decimal) in Linq
- How to do a string compare using regex and linq to sql
- How can I use and compare string datetime in c# linq to sql?
- C# LINQ code for two list compare and replace
- Convert string to long type and use in a linq query within asp.net MVC 5 C#
- Compare a string column from a joined table to an array of optional strings in LINQ / entity framework
- How to convert date to string and compare using Linq
- Compare input double with datatable string column values within a range using between query(SQL query to Linq on datatable c# )
- how to use linq to compare and replace duplicate string in one list
- C# - LinQ - Read text files, group by first column and order by last column?
- How can I do a simple "=" check and also a string compare in a LINQ predicate?
- Compare two lists with linq and lambda where one is string and other long
- How to sort text file by Column with LINQ using start and end column positions
- Linq Find Partial Text Match - Included code returns duplicate and everything except what it should
- compare list type year's value with datetime column in linq to sql query
- LINQ - .Any for class type list<string> and class type string
- C# Linq to check if the given list of string is available in either (oldNumber and newNumber) of the Column and return only the matched cell value
- DbFunctions or similar to compare time of day of a datetime type column in Linq to Entity Framework
- Split field a string and compare each value with string linq c#
- LINQ query compare DateTime column to DateTime string column
- LINQ to compare and excude/include different objects based on a similar type property
- string parsing in linq query and use anonymous type
- What ways exist with linq to compare if a case insensitive and culture using string exists within another
More Query from same tag
- Convert LINQ query syntax to method syntax w/ grouping
- How to calculate employees reporting to a manager recursively using LINQ?
- Select author of opinion
- Include filter child collection
- Left outer join now working linq object reference not set to an instance of an object
- Decimal contained in another decimal linq
- LINQ search filter logic
- Linq to Nested Lists
- Where comparison from array
- How to use FirstOrDefault inside Include
- The type '' cannot be used as type parameter 'T' in the generic type or method ''. There is no implicit reference conversion from '' to ''
- How to dynamic use SqlFunctions.PatIndex
- LINQ doesn't end with certain characters
- Linq case statement on boolean field depending on int value
- Fetch data From Two tables using Linq
- Performance improvement for linq query with distinct
- Break from function composition on condition using LINQ
- MVC LINQ query to populate model with a one-to-many and many-to-one tables
- Controls Collection and .Where?
- LINQ: transparent record inserting and updating
- linq select many issue
- Linq to count from inner lists
- Looking for help finding an element in an XML XDocument and updating attributes
- EF related data dropdown list
- Instantiate empty IQueryable for use with Linq to sql
- Linq to XML: How do you determine if something of type "var" is null or empty?
- DataContext to DB
- HTML Agility Pack and LINQ
- Simple linq query using group in order to return a one to many relationship
- How to use objects instead of anonymous Types