How to know if a field is numeric in Linq To SQL

前端 未结 7 1100
日久生厌
日久生厌 2020-12-15 11:18

I need to select the rows of a table where a column value is numeric, any Help?

EDIT: I have a varchar column and I need to select the ones that are numbers and the

7条回答
  •  鱼传尺愫
    2020-12-15 11:46

    Open up your DBML (LINQ-to-SQL) file in an XML editor, go down to the end of the file and paste this just before the '' node:

    
        
        
    
    

    Now, you can use the already-in-SQL function called "ISNUMERIC". Here's how:

    var blah = myDataContext.Accounts.Where(account=>
        myDataContext.ISNUMERIC(account.ID) == true);
    

    There you go :)

    You may also find these functions useful to copy:

    
      
    
    
      
    
    

提交回复
热议问题