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
LIKE '%str') or
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();
you can use this (i haven't tested the code)
var result = db.Table.Where(x => x.columnA.Contains("A")).ToList();
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
var result = db.Table.Where(x => x.columnA.ToString() == "A").ToList();
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();
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.
- LINQ compare string and DB column type 'text'
- The given value of type String from the data source cannot be converted to type int of the specified target column
- How to compare a string column to a number (as a decimal) in Linq
- Compare a string column from a joined table to an array of optional strings in LINQ / entity framework
- Compare input double with datatable string column values within a range using between query(SQL query to Linq on datatable c# )
- compare list type year's value with datetime column in linq to sql query
- DbFunctions or similar to compare time of day of a datetime type column in Linq to Entity Framework
- LINQ query compare DateTime column to DateTime string column
- How can I sort a string of text followed by a number using LINQ
- NHibernate uses wrong column type for LINQ contains query (varchar to nvarchar)
- C# Linq string compare with indexOf
- LINQ to SQL - select where text like string array
- Case insensitive string compare in LINQ expression
- return type of linq group by multiple column
- Linq Query : Cannot convert type IEnumerable<string> to string changing .ToString() to (string)
- linq join on guid and string column
- LINQ Source Code Available
- Creating a LINQ Select expression dynamically from string column names
- How to write LINQ query with column name as parameter still in a type safe way
- How to compare int with string in linq where clause
- How come Linq functions are available on a variable which can be of a type string
- Linq Order by when column name is dynamic and pass as a string to a function
- Cannot convert source type to target type List<KeyValuePair> Linq
- Linq Query to Compare with List of string values
- Split each two-word string in a list, compare if same and count using Linq
- LINQ to NHibernate - compare guid with string
- LINQ to Entities string to decimal a column
- Sum a string column in linq
- Convert string to long type and use in a linq query within asp.net MVC
- creating Linq to sqlite dbml from DbLinq source code
- DBContext Linq to entity read uncommitted
- How to get difference between two DataTables
- Does LinQ Any() cast all items in a collection?
- How to use GroupBy with Join in Linq's method syntax in EF?
- LINQ Query that omits any duplicate IDs
- Create XML based on text tree
- 'Ticks' is not supported in LINQ to Entities
- linq orderby not sorted asc not working
- How to handle NULL object property with FirstOrDefault using Linq
- How to delete and re-insert entities in linq?
- Trying to Filter XML using XPath
- Image retrieval optimisation with LINQ
- C# - LINQ - shortest distance by GPS latitude and longitude
- Binding XML to Combobox
- Entity Framework: Dynamically generate multiple OR condition on JOIN
- how to copy one column data to another column with in the same table using linq?
- Order by sort order that is greater than 0
- How to do the following in Dynamic Linq using System.Linq.Dynamic namespace
- How to bind a Drop Down control with a collection using Query expression syntax?
- How Can I add an XSI type to an element that is being serialized using LINQ