C# 如何检索字母数字行?
我有一张桌子如下:C# 如何检索字母数字行?,c#,entity-framework,linq-to-entities,C#,Entity Framework,Linq To Entities,我有一张桌子如下: | Id |FirstName|LastName|IdentityNumber| 1 A B A2301c12 2 C D 12345 3 E F ABcD1 4 G H AAA7622II 然后我希望通过LINQtoEntities只获取列值为字母数字(包含字母和数字)的记录 期
| Id |FirstName|LastName|IdentityNumber|
1 A B A2301c12
2 C D 12345
3 E F ABcD1
4 G H AAA7622II
然后我希望通过LINQtoEntities只获取列值为字母数字(包含字母和数字)的记录
期望输出:
| Id |FirstName|LastName|IdentityNumber|
1 A B A2301c12
3 E F ABcD1
4 G H AAA7622II
注意:Iam使用Entity Framwork 6和oracle的devart provider。您可以尝试以下查询:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
您可以尝试以下查询:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
您可以尝试以下查询:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
您可以尝试以下查询:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
此查询假设从表中检索所有数据(可能是大量数据),然后才在客户端对数据进行排序:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
我们建议您使用以下代码:
var results = dbcontext.TESTALPHANUMs.Where(p => OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "[A-Za-z]+[0-9]*$") && ! OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "^[A-Za-z]*$")).ToList();
在这种情况下,只从数据库中检索必要的数据。此查询假定从表中检索所有数据(可能是大量数据),然后才在客户端对数据进行排序:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
我们建议您使用以下代码:
var results = dbcontext.TESTALPHANUMs.Where(p => OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "[A-Za-z]+[0-9]*$") && ! OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "^[A-Za-z]*$")).ToList();
在这种情况下,只从数据库中检索必要的数据。此查询假定从表中检索所有数据(可能是大量数据),然后才在客户端对数据进行排序:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
我们建议您使用以下代码:
var results = dbcontext.TESTALPHANUMs.Where(p => OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "[A-Za-z]+[0-9]*$") && ! OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "^[A-Za-z]*$")).ToList();
在这种情况下,只从数据库中检索必要的数据。此查询假定从表中检索所有数据(可能是大量数据),然后才在客户端对数据进行排序:
var res = dataSource
.MyTable
.AsEnumerable()
.Where(s => s.IdentityNumber.Any(Char.IsDigit) && s.IdentityNumber.Any(Char.IsLetter));
我们建议您使用以下代码:
var results = dbcontext.TESTALPHANUMs.Where(p => OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "[A-Za-z]+[0-9]*$") && ! OracleFunctions.RegexpLike(p.IDENTITYNUMBER, "^[A-Za-z]*$")).ToList();
在这种情况下,只从数据库中检索必要的数据。@Amir此代码将数据移动到内存中,以应用
Char.IsDigit
和Char.isleter
函数。我不确定是否有任何数据提供程序能够将其转换为正确的SQL(尽管您可以通过删除中间的AsEnumerable()
来尝试)。@Amir此代码将数据移动到内存中,以应用Char.IsDigit
和Char.isleter
函数。我不确定是否有任何数据提供程序能够将其转换为正确的SQL(尽管您可以通过删除中间的AsEnumerable()
来尝试)。@Amir此代码将数据移动到内存中,以应用Char.IsDigit
和Char.isleter
函数。我不确定是否有任何数据提供程序能够将其转换为正确的SQL(尽管您可以通过删除中间的AsEnumerable()
来尝试)。@Amir此代码将数据移动到内存中,以应用Char.IsDigit
和Char.isleter
函数。我不确定是否有任何数据提供程序能够将其转换为正确的SQL(尽管您可以通过删除中间的AsEnumerable()
来尝试)。