contains

IEnumerable<T>.Contains with predicate

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". Currentl...

LINQ .Startswith or .Contains problems in VB.NET4

Hi! This may be a newbie question... In my code I can easily use "where Obj.Feld = String", but using "where Obj.Feld.StartsWith("a")" doesn't work. See the following two functions: Public Function EntriesByFileName(ByRef Database() As Entry, ByVal Filename As _ String) As IEnumerable(Of Entry) Dim Result As IEnumerable...

Treeset.contains() problem.

So I've been struggling with a problem for a while now, figured I might as well ask for help here. I'm adding Ticket objects to a TreeSet, Ticket implements Comparable and has overridden equals(), hashCode() and CompareTo() methods. I need to check if an object is already in the TreeSet using contains(). Now after adding 2 elements to t...

How can I extract ArrayList from HashMap and loop through it in Java?

I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String, ArrayList<String>>(); ... and I populate this by storing for every name (key), a list of names (value). So: ArrayList<String> saAccused = new ArrayList<String>(); // populate 'saAccused' ArrayList ... // done populating theAccused.put(sAc...

iPhone: detect any point in a rect in another rect

Is there any way to detect if any point in a given rect is contained inside of another, larger, rect? I'm trying to figure out when certain rects are on the screen (for memory management to deallocate the ones that aren't) but the rects are large and so sometimes only parts of them will be on the screen but I still need to have them load...

jquery - check if parent does not contain element with the class

I'm having a problem with trying to find out whether the parent element does not have the element with the specific class like so: // after clicking on the button inside of the form - get the instance of the parent form var par = $(this).parent('form'); if(!par.has('warn')) { // do something } Any idea how to ac...

Jquery: How to see if string contains substring

I have a shoppingcart that displays product options in a dropdown menu, and I want to make some other fields on the page only visible if they select "Yes" in the previous option. The problem is that the shopping cart also includes the price modifier in the text, and that can be different for each product. So if I do this it works: $(...

Determining if a Git repository contains a particular commit

...

Using 'Contains' Clause Like 'IN' SQL Clause in Entity Framework

I am working on a tag cloud application. There are 3 database tables. Content: ContentID, Text Tag: TagID, Name TagRelation: TagRelationID, TagID, ContentID The code below is wrong. Because 'Contains' clause doesn't take a list of parameters like the 'IN' SQL clause. Is there an alternative clause that I can use to make this code wor...

XSL hyperlink rewriting without recreating the element

Hi, I worked out an XSL template that rewrites all hyperlinks on an HTML page, containing a certain substring in the href attribute. It looks like this: <xsl:template match="A[contains(@href, 'asp')]"> <a> <xsl:attribute name="href"> <xsl:value-of select="bridge:linkFrom($bridge, $base, @href, 'intranet')" /> ...

Find an attribute that contains a ceratin string and modifying its Value in c# using LINQ

Hello, I'm trying to find the first attribute in an xml file that contains the string "name" (case insensitve) in it and then change its value. Here is an example of my xmls //XML 1 <CtApproachTypes DataclassId="1992A9CE-B048-4676-BFD4-FD81F1A65401" EntityId="1992A9CE-B048-4676-BFD4-FD81F1A65401" Name="PAR" Remark="No Rema...

What does Collection.Contains() use to check for existing objects?

I have a strongly typed list of custom objects, MyObject, which has a property Id along with some other properties. Let's say that the Id of a MyObject defines it as unique and I want to check if my collection doesn't already have a MyObject object that has an Id of 1 before I add my new MyObject to the collection. I want to use if(!Lis...

Batch command for if filename contains "X"?

I'm trying to run a batch file through a folder and delete files if their name contains a certain string. I'm not sure how to check the filename against the string though. ...

Jquery: how hide/show tree elements based on search criteria?

Hello, I have a tree view based on < ul > and < li > tags. I am trying to hide the branches based on filter text. Here is my show/hide code: $("#filter").change(function(){ var tval=$(this).val(); $("li").show(); $("li").not(":contains(\'"+tval+"\')").hide(); $("li").is(":contains(\'"+tval+"\')").show(); ...

LINQ BuildContainsExpression With OR conditions

Hi, I'm trying to get the following SQL query to work in LINQ: Select id from table1 where id in (1,2) or canceledId in (1,2) I'm using BuildContainsExpression to achieve the "IN" condition, but I can't figure out how to implement the "or" condition. My shot in the dark is as follows: var identifiers = new List<int> {1,2}; va...

JQuery string contains check

Hello, I need to check a string to see if it contains another string. var str1 = "ABCDEFGHIJKLMNOP"; var str2 = "DEFG"; What function do I use to find out if str1 contains str2? Cheers, Thomas. ...

How to write WHERE IN query in LINQ to Entity?

Possible Duplicate: 'Contains()' workaround using Linq to Entities? Hi every one. I would like to know how to write the "WHERE IN" query in LINQ to Entity. I have tried with the following code: string[] strings = GetRequest("userID").Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); List<long> longs = strings....

fastest way to see if IEnumerable<T> contains item based on criteria

Sort of a Linq beginners question, but is there a simple built-in way to optimize this: bool containsItemWithValue42 = items.Where(i => i.Value == 42).Count() > 0; I would like Linq to stop iterating as soon as it found a match. ...

Is a hashset needed for contains with List(of String) Vb.net

Would the following: Dim stringlist As List(Of String) Dim stringlisthas = stringlist.Contains("thing1") be any slower than Dim stringlist As List(Of String) Dim stringlisthash As New HashSet(Of String)(stringlist) Dim stringlisthas = stringlisthash.Contains("thing1") Is a hashset needed for contains? ...

Entity Framework select from link table with list

Using the following database table structure: Order Table: OrderId OrderName OrderItem Table: OrderId ItemId Item Table: ItemId ItemName I have an 'Order' entity that has an 'Items' collection. What I need to do is return all orders that contain certain items. Example: All orders with items with id: 1, 4 and 5 (I don't care if it ha...