Linq query doesn't support System.String

First of all, I have seen questions similar to this, but I’ve not resolve my problem for this reason I am asking here.

I am working with SQL Server and I’d like to transform from LINQ to SQL, in C#.
This is my table:
enter image description here

  • SQL 2005/8 Quirky update “black arts”
  • asp.net via kerberos integrated windows authentication to sql server
  • Trouble hosting SQL Server database via Plesk panel
  • Is this select field really necessary if its not labeled/referenced?
  • SQL Server auto increment a column without primary key
  • Is “CLR Integration” enabled at a database level or the server/instance level?
  • This is my code:

      [Table]  public class h
        {
    
           [Column] public string username;
           [Column(IsPrimaryKey =true)] public string password;
           [Column] public int id; 
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                bsdDataContext cc = new bsdDataContext("Data Source=localhost;Initial Catalog=toolsdb;Persist Security Info=True;User ID=sa;Password=0359");
    
                Table<h> h_table = cc.GetTable<h>();
    
                IQueryable<string> query = from item in h_table where item.username.Contains('o') orderby item.username.Length select item.username.ToString();
    
                foreach (string item in query)
                {
                    Console.WriteLine(item);
                }
    
    
    
                Console.ReadKey();
            }
    

    And when I build my program I get the error, System.NotSupportedException: ‘, String operators for type ‘System.String’ are not supported.
    enter image description here

  • Change Database Column Design in SQL Server
  • SSMS Object Explorer - Select Top N Rows missing when connected to Azure DB
  • Is there a way to retrieve inserted identity as well as some values from the query in an INSERT SELECT?
  • How to fix SQL connection leaks in this code?
  • hash a SQL row?
  • Compare two DATETIME only by date not time in SQL Server 2008
  • 2 Solutions collect form web for “Linq query doesn't support System.String”

    You’re calling the Contains() overload that takes a char.

    That’s probably confusing the LINQ engine.

    Change ' to " so that you’re passing a string and it should work.

    Also, don’t call .ToString(); that’s probably also messing it up.

    contains always finding string value

        IQueryable<string> query = from item in h_table where item.username.Contains('o') orderby item.username.Length select item.username.ToString();
    

    replace above with

        IQueryable<string> query = from item in h_table where item.username.Contains("o") orderby item.username.Length select item.username;
    
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.