English 中文(简体)
我如何问,从一封信开始,某个领域究竟是什么时候?
原标题:How do I query for when a field doesn t begin with a letter?

我的任务是在我们的搜索中增加一个选择,在某个领域(doesn t)开始使用字母字母开始的情况下,再回去结果。 (.StartsWith(letter) part wasn t sough.

但是,我对如何取得不属于A-Z组的产物感到沮丧,同样希望它产生一些中等效率的基调。

任何帮助——感谢。

最佳回答

在C#中,将db作为数据背景使用以下建筑:

var query = from row in db.SomeTable
            where !System.Data.Linq.SqlClient.SqlMethods.Like(row.SomeField, "[A-Z]%")
            select row;

This is only supported in LINQ to SQL queries. All rules of the T-SQL LIKE operator apply.

你们也可以使用更有效的解决办法:

var query = from row in db.SomeTable
            where row.SomeField[0] <  A  || row.SomeField[0] >  Z 
            select row;

This gets translated into SUBSTRING, CAST, and UNICODE constructs.

最后,你可以使用VB,在这种地方,似乎当地人支持类似方法。

问题回答

虽然在使用彩票(<条码>[a-f]%(例如)的电离层电离层电离层电离层电离层电离层电离层电离层信号中能够检查一系列特性,但我只看到了一条支线,可以直接支持这种特性。

两点思想:

首先,如果所设定的结果相对较小,你可以填写<代码>。

或者,如果你有能力改变数据模型,你可以设立更多的领域或表格,帮助对数据进行索引,改进搜索。

页: 1

下面根据Ruslan的评论做了改动。

我完全不赞成这样做,因为我从未尝试过,没有附近的编辑来尝试,但我所尝试的第一项事情是。

var query = from x in db.SomeTable
            where x.SomeField != null &&
                  x.SomeField.Length >= 1 &&
                  x.SomeField.Substring(0, 1).All(c => !Char.IsLetter(c))
            select x;

现有的准则是,LLQ未能将其转换为Q。





相关问题
IEnumerable to array of parameter

Using linq? and XML is there a way to convert this IEnumerable to a string array of the value parameter? List<string> idList = new List<string>(); foreach (XElement idElement in word....

linq query for tag system - search for multiple tags

I have two tables, Tags(tagid, postid, tagname) and posts(postid, name, ...) now i want to make a query that returns me all posts that have a generic amount of tags. like: i want all posts that have ...

Linq operations against a List of Hashtables?

I m working with a set of legacy DAO code that returns an IList, where each Hashtable represents the row of a dynamically executed SQL query. For example, the List might contain the following records/...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

How to filter duplicate list items

i have list of items IList with data that looks list this: GenId TestMode 1 0 1 1 3 0 3 1 4 NULL 2 NULL i want to remove the index ...

C# Grouping/Sorting a Generic List<> using LINQ

Im looking to group and sort a Generic List<>. I have a list of objects representing files and each of these objects has a FileName, FileType and FileDate property. FileType is defined as an ...

热门标签