We help IT Professionals succeed at work.

Filter my data by the commitID

125 Views
Last Modified: 2020-04-09
I have a search page that filter the commitID


If the user enter 4534565434 - > I'll get the record
if the user enter 488573377 -> I'm not getting any record

so it only get the first commitID  

my data in the database looks like this:
RuleDetailID                  CommitID
39                                       4534565434, 488573377
40                                        7876545665
41                                        678765456765
42                                       4958574757
43                                      9878787678, 39484723, 494858573
44                                      2343454345
48                                     3434433444
49                                     6756765443
51                                     6444345556, 32423443


                    //Filter CommitID
                    if (model.SelectedCommitID != null)
                    {
                        list = list.Where(x => x.CommitID != null && model.SelectedCommitID.Any(m => Array.IndexOf(x.CommitID.Split(','), m) > -1));
                    }




                    //Filter CommitID
                    if (model.SelectedCommitID != null)
                    {
                       list = list.Where(x => x.CommitID != null && model.SelectedCommitID.Any(m => Array.IndexOf(x.CommitID.Split(','), m) > -1));
                    }

Open in new window

Comment
Watch Question

lulu50Web application

Author

Commented:
This is how my data in HTML

<select name="CommitIDListID" class="btn btn-default dropdown-toggle" id="CommitIDListID" multiple="multiple">
                                        <option value="2343454345">2343454345</option>
                                        <option value="32423443">32423443</option>
                                        <option value="3434433444">3434433444</option>
                                        <option value="39484723">39484723</option>
                                        <option value="4534565434">4534565434</option>
                                        <option value="488573377">488573377</option>
                                        <option value="494858573">494858573</option>
                                        <option value="4958574757">4958574757</option>
                                        <option value="6444345556">6444345556</option>
                                        <option value="6756765443">6756765443</option>
                                        <option value="678765456765">678765456765</option>
                                        <option value="7876545665">7876545665</option>
                                        <option value="9878787678">9878787678</option>
                                        <option value="d">d</option>
                                        <option value="test">test</option>
                            </select>
it_saigeDeveloper
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
What is the type of SelectedCommitID.

-saige-
lulu50Web application

Author

Commented:
   public string[] SelectedCommitID { get; set; }


in the database

CommitID varchar(1000) Checked
Developer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
lulu50Web application

Author

Commented:
it_saige,

It works great!!!

list = list.Where(x => model.SelectedCommitID.Any(s => x.CommitID != null && x.CommitID.Split(',').Any(v => Equals(v.Trim(), s.Trim()))));

Thank you so much for everything.

I appreciate all the time you have spent to help me.

you are great and your skills/gift is amazing

the site shine because of you.

Great Heart.

Thank you
Lulu
it_saigeDeveloper
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Glad to help

-saige-
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.