code_junkie

binding to linq inherited types in asp.net

Nov 12th, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. Dim oComp As IEnumerable(Of Company)
  2. Dim oInd As IEnumerable(Of Individual)
  3.  
  4. oComp = From oP As Company In ERM.Parties _
  5. Where TypeOf (oP) Is Company And _
  6. oP.Name.StartsWith(sSearchString)
  7.  
  8. oInd = From oP As Individual In ERM.Parties _
  9. Where TypeOf (oP) Is Individual And _
  10. (oP.FirstName.StartsWith(sSearchString) Or _
  11. oP.LastName.StartsWith(sSearchString))
  12.  
  13. rptIndividuals.DataSource = oInd
  14. rptCompanies.DataSource = oComp
  15.  
  16. rptCompanies.DataBind()
  17. rptIndividuals.DataBind()
  18.  
  19. Dim oComp As IEnumerable(Of Party)
  20. Dim oInd As IEnumerable(Of Party)
  21.  
  22.  
  23. oComp = From oP In ERM.Parties _
  24. Where TypeOf (oP) Is Company And _
  25. CType(oP, Company).Name.StartsWith(sSearchString)
  26.  
  27. oInd = From oP In ERM.Parties _
  28. Where TypeOf (oP) Is Individual And _
  29. (CType(oP, Individual).FirstName.StartsWith(sSearchString) Or _
  30. CType(oP, Individual).LastName.StartsWith(sSearchString))
  31.  
  32. rptIndividuals.DataSource = oInd
  33. rptCompanies.DataSource = oComp
  34.  
  35. rptCompanies.DataBind()
  36. rptIndividuals.DataBind()
  37.  
  38. rptCompanies.DataSource = oComp.ToArray ()
Add Comment
Please, Sign In to add comment