contains

Compiled queries and “Parameters cannot be sequences”

倾然丶 夕夏残阳落幕 提交于 2019-12-08 17:34:21
问题 I thought that compiled queries would perform the same query translation as DataContext. Yet I'm getting a run-time error when I try to use a query with a .Contains method call. Where have I gone wrong? //private member which holds a compiled query. Func<DataAccess.DataClasses1DataContext, List<int>, List<DataAccess.TestRecord>> compiledFiftyRecordQuery = System.Data.Linq.CompiledQuery.Compile <DataAccess.DataClasses1DataContext, List<int>, List<DataAccess.TestRecord>> ((dc, ids) => dc

IEnumerable<T>.Contains with predicate

五迷三道 提交于 2019-12-08 14:26:28
问题 I need just to clarify that given collection contains an element. I can do that via collection.Count(foo => foo.Bar == "Bar") > 0) but it will do the unnecessary job - iterate the whole collection while I need to stop on the first occurrence. But I want to try to use Contains() with a predicate, e.g. foo => foo.Bar == "Bar" . Currently IEnumerable<T>.Contains has two signatures: IEnumerable<T>.Contains(T) IEnumerable<T>.Contains(T, IEqualityComparer<T>) So I have to specify some variable to

Check if a string contains all other strings

末鹿安然 提交于 2019-12-08 09:56:25
问题 I am trying to code a part of a software where I try to show the results that match search criteria. I have a textbox where I can type one or more words I want to search and a listview that contains 4 different columns and a dozen rows. The idea is that each listview row contains lots of words and I want to see only the rows that contain all the words I have typed in the textbox. I have finished the code that searches for one term only. The problem I am having is that I don't fully understand

Java - List of objects. Find object(s) with a certain value in a field

拜拜、爱过 提交于 2019-12-08 08:50:18
问题 I have two lists of objects. The objects in each list are different subclasses of the same class. I want to look at objects in list One, check the value of a particular field, and then see if there is/are any objects in list Two that have the same field value. What would be the best way to do this? 回答1: I believe this is more correct. This is the simplest, easiest solution to implement. for(TypeA itemA : listA) { for(TypeB itemB : listB) { if(itemA.field == ItemB.otherField) { //Do Whatever }

ArrayList's contains() method always returns false with custom object

自作多情 提交于 2019-12-08 07:40:55
问题 I'm having some troubles with getting on with my code, I'll give you an simple example (though it's going to be a little more complex, this simple code doesn't work properly either). class Sign { private String char; private Integer freq; public Sign(String c) { this.char = c; } @Override public boolean equals(Object o) { String check = (String)o; return check.equals(this.char); } @Override public int hashCode() { int hash = 7; hash = 31 * hash + this.char.hashCode(); return hash; } } I

CakePHP 2.1 find using contain with condition

ⅰ亾dé卋堺 提交于 2019-12-08 03:31:01
问题 I have the following models. Industry(id, name) Movie(id, name, industry_id) [Industry has many movies] Trailer(id, name, movie_id) [Movie has many trailers] I need to find 6 latest trailers for each Industry . Every movie does not need to have a trailer or can have multiple[0-n]. The results must contain array of movies with atleast one trailer. $this->Industry->find('all', array( 'contain' => array( 'Movie' => array( 'Trailer' => array( 'limit' => 1 ), 'order' => 'Movie.release DESC',

Pandas and apply function to match a string

拥有回忆 提交于 2019-12-08 00:53:53
问题 I have a df column containing various links, some of them containing the string "search" . I want to create a function that - being applied to the column - returns a column containing "search" or "other" . I write a function like: search = 'search' def page_type(x): if x.str.contains(search): return 'Search' else: return 'Other' df['link'].apply(page_type) but it gives me an error like: AttributeError: 'unicode' object has no attribute 'str' I guess I'm missing something when calling the str

HQL “Contains” statement howto?

浪子不回头ぞ 提交于 2019-12-07 17:31:38
问题 I have an entity that has a string property called Tags. I would like to query this entity based upon if a certain string is located in Tags property. So for example, I would have a function IList GetEntityByTag(string tag), this would return all Entity's that have the value of tag in their 'Tags' property. I tried going through the ICriteria approach... Expression.In(PropertyName, Value) but this is the exact opposite. I need something like Expression.In(Value, PropertyName). Perhaps IQuery

How to do a CONTAINS() on two columns of Full Text Index Search SQL

ε祈祈猫儿з 提交于 2019-12-07 13:10:25
问题 I have a table (MyTable) with the following columns: Col1: NameID VARCHAR(50) PRIMARY KEY NOT NULL Col2: Address VARCHAR(255) Data Example: Name: '1 24' Address: '1234 Main St.' and i did a full text index on the table after making the catalog using default params. How can I achieve the following query: SELECT * FROM MyTable WHERE CONTAINS(NameID, '1') AND CONTAINS(Address, 'Main St.'); But my query is returning no results, which doesn't make sense because this does work: SELECT * FROM

Check if a string contains specific characters using VBS script

[亡魂溺海] 提交于 2019-12-07 10:54:23
问题 My script is doing the following point : Retrieve all my selected folder files Class them by date (From the recent one to the older) Show them in a window Here is my VBS Script (I retrieve it here): Option Explicit Const PathMDB = "C:\Users\C8461789\Desktop\test_script" MsgBox TriRepertoire,,"Enumération " & PathMDB '---lister les fichiers du répertoire --- Function TriRepertoire() Dim fso, fichier, fileItem Dim i, imax, z, valeur, cible, liste Set fso = CreateObject("Scripting