• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 792
  • Last Modified:

LINQ query requesting that the object type declared rather than bing implicit

oEngine = New FileHelperEngine(GetType(CUPSMapping))
 Dim oMappings As CUPSMapping() = CType(oEngine.ReadFile(Filename), CUPSMapping())

Dim query = From oMap In oMappings
                        Select oMap

The error message when mouse over 'query' is this.  Linq has been imported

Variable declaration without an 'AS' clause; type of object assumed
1 Solution
Either put "Option Infer On" at the top of the code file, or change it at the project level in the project properties compile tab.

Option Infer Statement
Kyle AbrahamsSenior .Net DeveloperCommented:
Dim query = From oMap In oMappings
                        Select oMap

should be:

dim query as List(of CupsMapping) = From  oMap In oMappings
                        Select oMap

'It's complaining that query type is not defined.  You need to specify query as something.

Is query correct or is it truly the result?
käµfm³d 👽Commented:
I think instead that the problem is on the range variable:

Dim query = From oMap As CUPSMapping In oMappings
                        Select oMap

Open in new window

If it were as ged325 describes, then what would you do when you were SELECTing an anonymous type!!!

On a side note, what is the purpose of the LINQ query anyway? You are merely selecting with nothing else. The net effect is you get back an IEnumerable(Of CUPSMapping). An array should already be enumerable. Are you passing the result of this query to some other function which has an explicit IEnumerable(Of CUPSMapping) signature?
AlyantoAuthor Commented:
Bloody marvelous, thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now