.Net:- Error – ‘System.Data.DataRowCollection’ does not contain a definition for ‘OfType’ and no extension method ‘OfType’ accepting a first argument of type ‘System.Data.DataRowCollection’ could be found

Background

Still here trying to steal that same old code.

 

Lineage

  1. .Net:- Compile Error – ‘System.Data.DataRow’ does not contain a definition for ‘Field’ and no extension method ‘Field’ accepting a first argument of type ‘System.Data.DataRow’
    Link

 

Error Message

Textual


'System.Data.DataRowCollection' does not contain a definition for 'OfType' and no extension method 'OfType' accepting a first argument of type 'System.Data.DataRowCollection' could be found

Image

Explanation

The error states that

  1. The System.Data.DataRowCollection object is missing the Field Property
  2. And, that I have yet to provide an extension method else where

Remediation

The clear is unambiguously using LINQ, so reached for it.

 

C#

using System.Linq;

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s