views:

93

answers:

3

I wanna do something like this. I know it’s wrong:

 var a = from h in xdoc.Root.Elements()
         where h.Element().value like = "1234"
         select h;
+5  A: 

I think that you want to get the elements that Contains the 1234 value:

var a = from h in xdoc.Root.Elements()
         where h.Element().Value.Contains("1234") // like '%1234%'
         select h;

For the SQL-ish like '%value' you can use EndsWith, and for like 'value%' StartsWith

CMS
+1  A: 

Use the helper methods of the String class, like StartsWith or EndsWith.

Konamiman
+5  A: 
var a = from h in xdoc.Root.Elements()
        where h.Element.value.Contains("1234") 
        select h

This would generate a 'LIKE' statement in the background.

James
thx alot thats working perfectly. and how can i do that h.Element.Name?? coz Element.Name doest have "Contains".
cagin
any string in .NET should have a Contains method.
James