Home

How to force convert to VARCHAR in LINQPAD?

I have a simple convert query that I am trying to rewrite in LINQPAD.
SELECT * FROM MS_CUSTOMER_MASTER_GRID MCMG
	WHERE MCMG.[Cust Address Line 1] != Convert(varchar,MCMG.[Cust Address Line 1])




Thanks!

Comments

  • I'm not sure there is any LINQ-to-SQL method which can be used to translate into CONVERT(). But you could use direct ExecuteQuery() methods to embed this query in your c# statements script with typed objects.
    CREATE TABLE MS_CUSTOMER_MASTER_GRID
    (
      [Cust Address Line 1] NVARCHAR(255)
    )
    
    INSERT MS_CUSTOMER_MASTER_GRID
    VALUES ( N'Abc' ), ( N'😀' )
    this.ExecuteQuery<MS_CUSTOMER_MASTER_GRID>(
      @"SELECT * FROM MS_CUSTOMER_MASTER_GRID MCMG
        WHERE MCMG.[Cust Address Line 1] != Convert(varchar,MCMG.[Cust Address Line 1])").Dump();
    Result:
    IEnumerable<MS_CUSTOMER_MASTER_GRID> (1 item)
    CustAddressLine1
    😀
Sign In or Register to comment.