I'm using a LINQ query to translate data inside a DataTable
object to be a simple IEnumerable
of a custom POCO object.
My LINQ query is:
Dim dtMessages As DataTable
'...dtMessages is instantiated ByRef in a helper data access routine... '
Dim qry = From dr As DataRow In dtMessages.Rows
Select New OutboxMsg With {
.ComputerID = dr(dcComputerID),
.MessageData = dr(dcMessageData),
.OutBoxID = dr(dcOutBoxID),
.OutBoxReceivedID = dr(dcOutBoxReceivedID),
.TrxDate = dr(dcTrxDate)
}
However, the compiler is throwing a warning message under dr As DataRow
with the message:
Option Strict On disallows implicit conversions from 'Object' to 'System.Data.DataRow'.
Why am I getting this error and what do I need to do to fix it? I would have thought that dtMessages.Rows
returned a collection of type DataRow
. Is this not correct?
Option Strict
! I kid, I kid. – Olivette