Search Enhancments

Jun 23, 2011 at 3:00 PM

I want to be able to search not only the ticket.title, but the ticket.details and the comments.comments. I've been able to add the functionality to search the details by modifying App_code/Tickets.cs as noted below:

----- CODE SAMPLE

return from p in GetTickets(db, active)
    where
    ((
    p.title.Contains(keywords[0]) &&
    p.title.Contains(keywords[1]) &&
    p.title.Contains(keywords[2]) &&
    p.title.Contains(keywords[3]) &&
    p.title.Contains(keywords[4]) &&
    p.title.Contains(keywords[5]) &&
    p.title.Contains(keywords[6]) &&
    p.title.Contains(keywords[7]) &&
    p.title.Contains(keywords[8]) &&
    p.title.Contains(keywords[9])
    )

// BEGIN NEW CODE
    ||
    (
    p.details.Contains(keywords[0]) &&
    p.details.Contains(keywords[1]) &&
    p.details.Contains(keywords[2]) &&
    p.details.Contains(keywords[3]) &&
    p.details.Contains(keywords[4]) &&
    p.details.Contains(keywords[5]) &&
    p.details.Contains(keywords[6]) &&
    p.details.Contains(keywords[7]) &&
    p.details.Contains(keywords[8]) &&
    p.details.Contains(keywords[9])
    ))&&

// END NEW CODE

    p.submitter == (usr < 0 ? p.submitter : usr) &&
    p.submitted >= dtFrom &&
    p.submitted <= dtTo &&
    (prty == 0 ? true : p.priority == prty) &&
    (stat == 0 ? true : p.ticket_status == stat) &&
    (!onlyOpen ? true : p.ticket_status != 5) &&
    (grp == 0 ? true : (
    (p.sub_unit2.unit_ref == grp) ||
    (p.sub_unit.unit_ref == grp))) &&
    (subgrp == 0 ? true : (
    (p.originating_group == subgrp) ||
    (p.assigned_to_group == subgrp)))
    select p;

------ END CODE SAMPLE

How can I added comments into this search? Essentially I want to be able to enter keywords in the title search box and return any tickets that have those keywords in any of these three fields.

 

Thanks for any help.

Coordinator
Jun 23, 2011 at 8:19 PM

Pretty much the same thing, comments have a field .comment that is just a VARCHAR(MAX) - so it would be searched just the same.