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...
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...
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...
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...
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...
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...
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:
$(...
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...
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')" />
...
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...
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...
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.
...
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();
...
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...
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.
...
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....
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.
...
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?
...
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...