contains

c# contains part of string

最后都变了- 提交于 2019-12-05 03:09:40
So I have a list with Materiel-objects. In Materiel I have 15 get and set methods. I want to construct a search-method that loops all the objects in the list, and all of the variables in each Materiel-object. The looping part is easy enough, but I'm struggling with the string-contains-part. The search term could for instance be "acto", and I should get a hit for "Tractor". I have tried using the string-Contains class, but as far as I can figure out, it only checks the string beginning in position 0. So "Tra" gets a hit, but not "acto". Is there any build in classes, or should I program one

Strange behaviour with Fulltext search in SQL Server

纵然是瞬间 提交于 2019-12-05 03:04:18
I have MyTable with a Column Message NVARCHAR(MAX). Record with ID 1 contains the Message '0123456789333444 Test' When I run the following query DECLARE @Keyword NVARCHAR(100) SET @Keyword = '0123456789000001*' SELECT * FROM MyTable WHERE CONTAINS(Message, @Keyword) Record ID 1 is showing up in the results and in my opinion it should not because 0123456789333444 does not contains 0123456789000001. Can someone explain why the records is showing up anyway? EDIT select * from sys.dm_fts_parser('"0123456789333444 Test"',1033,0,0) returns the following: group_id phrase_id occurrence special_term

Delete nodes with certain value from XML using TSQL

邮差的信 提交于 2019-12-05 02:57:41
I'm trying to parse a piece of XML and remove nodes that contain certain values. I know how to remove them if the value is exact, but I want to use something like a "contains". This works to delete exactly: update @XML set data.modify('delete //Message[text() = "customer has deleted their account"]') But I want to delete where the "Message" node just contains the text, something like: update @XML set data.modify('delete //Message[contains(text(), "customer")]') However this returns the error: XQuery [@XML.data.modify()]: 'contains()' requires a singleton (or empty sequence), found operand of

How to use LINQ Contains() to find a list of enums?

余生颓废 提交于 2019-12-05 02:12:54
I have an enum called OrderStatus , and it contains various statuses that an Order can be in: Created Pending Waiting Valid Active Processed Completed What I want to do is create a LINQ statement that will tell me if the OrderStaus is Valid, Active, Processed or Completed. Right now I have something like: var status in Order.Status.WHERE(status => status.OrderStatus == OrderStatus.Valid || status.OrderStatus == OrderStatus.Active|| status.OrderStatus == OrderStatus.Processed|| status.OrderStatus == OrderStatus.Completed) That works, but it's very "wordy". Is there a way to convert this to a

In C#, best way to check if stringbuilder contains a substring

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 01:22:57
I have an existing StringBuilder object, the code appends some values and a delimiter to it. Now I want to modify the code to add the logic that before appending the text I want to check if it really exist in string builder variable or not? If not, then only append otherwise ignore. What is the best way to do so? Do I need to change the object to string type? Need a best approach that would not hamper a performance. public static string BuildUniqueIDList(context RequestContext) { string rtnvalue = string.Empty; try { StringBuilder strUIDList = new StringBuilder(100); for (int iCntr = 0; iCntr

Select div (or other element) that class contains “grap” (o other specified word) for example

浪尽此生 提交于 2019-12-04 22:50:38
First of all; example of HTML code: <div class"grap1"> some conetent</div> <div class"grap2"> some conetent</div> <div class"grap3"> some conetent</div> <div class"blabla">some content></div> And now i want to select divs that class contains "grap" word somewhere is class name (so in this case first three divs). How can i achieve that ? This is not working: http://api.jquery.com/attribute-contains-word-selector/ Use the attribute contains selector : $('div[class*="grap"]') Depending on your particular use-case, you could try the attribute prefix selector: var $grapDivs = $('div[class|="grap"]'

Contains statement

南楼画角 提交于 2019-12-04 21:17:16
问题 I am not understanding the importance of CONTAINS statement in fortran 90 For example PROGRAM BLABLA IMPLICIT NONE INTEGER :: i,j,k i = 1; j = 1;k =1 PRINT *, i,j,k CALL ABC(i,j,k) PRINT *, i,j,k CONTAINS SUBROUTINE ABC(r,s,t) IMPLICIT NONE INTEGER, INTENT(IN) :: r,s INTEGER, INTENT(OUT) :: t t = r + s END SUBROUTINE ABC END PROGRAM BLABLA and one by defining subroutines outside the main program. I understand for functions, one need to specify the type of the function, but for subroutines it

C# Filter List to remove any double object

╄→гoц情女王★ 提交于 2019-12-04 19:26:47
Have searched ant tested many examples in this forum but can't get a fully working method. I am using linq to bulk insert a list of entity classes (RemoteReadings). Due to unique constraints I need to filter out any items already inserted. Uniqiuness is composed of 2 columns meterid and datetime in RemoteReadings table. // approx 5000 records (I need to do this in batches of 2000 due to a // constraint in L2S,but can do this after get this working) List<RemoteReading> lst = createListFromCSV(); // Option 1: // This does not work as am comparing memory list to db list. I need to use contains()

Using Linq to do a Contains with multiple values

和自甴很熟 提交于 2019-12-04 17:32:30
问题 I have a medication table that I'm looking for certain drug names, but I need to search for multiple names. Here is where I currently am with it. string[] names = new string[2]; names[0] = "apixaban"; names[1] = "desirudin"; var meds = (from m in Medications where names.Any(m.BrandName.Contains) || names.Any(m.GenericName.Contains) select m); What I have isn't working, and I'm currently stuck. I know I'm close, but I can't quite figure out what's wrong. EDIT For clarification, if the name I'm

List<T>.Contains and T[].Contains behaving differently

亡梦爱人 提交于 2019-12-04 15:56:27
问题 Say I have this class: public class Animal : IEquatable<Animal> { public string Name { get; set; } public bool Equals(Animal other) { return Name.Equals(other.Name); } public override bool Equals(object obj) { return Equals((Animal)obj); } public override int GetHashCode() { return Name == null ? 0 : Name.GetHashCode(); } } This is the test: var animals = new[] { new Animal { Name = "Fred" } }; Now, when I do: animals.ToList().Contains(new Animal { Name = "Fred" }); it calls the right generic