This is my code:
var icdCodes = DbContext.MasterIcd.Select(x => x.IcdCode).AsQueryable();
var count = icdCodes.Where(x => !x.Any(char.IsDigit)).Count();
Run Code Online (Sandbox Code Playgroud)
I'm trying to find those IcdCodes which doesn't contain any characters. But using count throws the following error: “Internal .NET Framework Data Provider error 1025.”
As mentioned in Internal .NET Framework Data Provider error 1025 I'm using AsQuerable() but still getting the error. Please help
The AsQueryable() does not solve this other cause of the same error. As also explained in Casting LINQ expression throws "Internal .NET Framework Data Provider error 1025.", the problem is that Where(x => !x.Any(char.IsDigit)) can't be translated to SQL.
The C# code you use treats a string as a char array and calls a function that uses a Unicode lookup table to check if each character is a digit.
The T-SQL variant of this is ISNUMERIC. See How to know if a field is numeric in Linq To SQL:
DbContext.MasterIcd
.Select(x => x.IcdCode)
.Where(i => SqlFunctions.IsNumeric(i) == 1)
.ToList();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
80 次 |
| 最近记录: |