0

Using this statement I am not getting any data:

Dim sFilter As String = "16,22,34"
e.QueryableSource = New myworkspace.myentity().mytable.Where(Function(p) sFilter.Split(",").Contains(p.mytablekey))

whereas I am with this statement (or with keys 22 or 34):

e.QueryableSource = New myworkspace.myentity().mytable.Where(Function(p) p.mytablekey= 16)

Why is the former statement not giving the desired result?

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
Corobori
  • 303
  • 3
  • 13
  • @Corobori If you use [`Option Strict On`](https://stackoverflow.com/a/29985039/1115360) and correct any problems it finds, does the code work? – Andrew Morton Oct 16 '18 at 19:39
  • The 2nd statement is working just fine, that is the "Where(Function(p) sFilter.Split(",").Contains(p.mytablekey))" which isn't retrieving the information I am expecting – Corobori Oct 16 '18 at 19:40
  • 1
    `sFilter.Split(",")` returns an array of strings. `p.mytablekey= 16` suggests that `p.mytablekey` is an integer. Between the two of them, at least one of them is wrong. – Andrew Morton Oct 16 '18 at 19:41
  • @AndrewMorton Thank you, your comment put me on the right track. – Corobori Oct 16 '18 at 20:06
  • @AndrewMorton Missed the vb.net. Why didn't the first statement give a type error? – NetMage Oct 16 '18 at 21:28
  • @NetMage If Option Strict is off, it is free to change types to make them match. It doesn't have to change them the way that is wanted. – Andrew Morton Oct 17 '18 at 07:54

1 Answers1

0

This is the answer

Dim iKeys = New Integer() {16, 22, 24}
e.QueryableSource = New ProcaseSGC.ProcaseSGCEntities1().Tbl_Contacto.Where(Function(p) iKeys.Contains(p.F_CtoCod))
Corobori
  • 303
  • 3
  • 13