lulu50
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.S plit(','), m) > -1));
}
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
}
//Filter CommitID
if (model.SelectedCommitID != null)
{
list = list.Where(x => x.CommitID != null && model.SelectedCommitID.Any(m => Array.IndexOf(x.CommitID.Split(','), m) > -1));
}
What is the type of SelectedCommitID.
-saige-
-saige-
ASKER
public string[] SelectedCommitID { get; set; }
in the database
CommitID varchar(1000) Checked
in the database
CommitID varchar(1000) Checked
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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 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
Glad to help
-saige-
-saige-
ASKER
Open in new window