Avatar of lulu50
lulu50Flag for United States of America asked on

Filter my data by the commitID

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

ASP.NET.NET MVC.NET ProgrammingDatabasesC#

Avatar of undefined
Last Comment
it_saige

8/22/2022 - Mon
ASKER
lulu50

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>

Open in new window

it_saige

What is the type of SelectedCommitID.

-saige-
ASKER
lulu50

   public string[] SelectedCommitID { get; set; }


in the database

CommitID varchar(1000) Checked
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
it_saige

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
lulu50

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_saige

Glad to help

-saige-