SubSonic Alias/Where Clause
        Posted  
        
            by JohnBob
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by JohnBob
        
        
        
        Published on 2010-03-15T07:10:14Z
        Indexed on 
            2010/03/15
            7:19 UTC
        
        
        Read the original article
        Hit count: 708
        
Hey,
I want to convert the following SQL Query to a SubSonic Query.
SELECT [dbo].[tbl_Agency].[ParentCompanyID]
 FROM [dbo].[tbl_Agency]
 WHERE REPLACE(PhoneNumber, ' ', '') LIKE REPLACE('%9481 1111%', ' ', '')
I thought I would do it like below, but I just can't get it to produce valid SQL.
     //SubSonic
     string agencyPhoneNumber = "9481 1111";
     SubSonic.SqlQuery subQueryagencyPhoneNumber = new SubSonic.Select(Agency.ParentCompanyIDColumn.ColumnName);
            subQueryagencyPhoneNumber.From(Agency.Schema.TableName);
     //WHERE
     subQueryagencyPhoneNumber.Where("REPLACE(" + Agency.PhoneNumberColumn.ColumnName + ", ' ', '')").Like("%" + agencyPhoneNumber + "%");
Does anyone out there know how to fix this - I'm using SubSonic 2.2. I feel like I'm taking crazy pills here - this should be straightforward, right?
Cheers, JohnBob
© Stack Overflow or respective owner