Solved

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

Posted on 2012-03-12
4
775 Views
Last Modified: 2012-03-12
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
0
Comment
Question by:Alyanto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 37710446
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
http://msdn.microsoft.com/en-us/library/bb384665.aspx
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37710456
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?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37710521
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?
0
 
LVL 1

Author Closing Comment

by:Alyanto
ID: 37710562
Bloody marvelous, thank you
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question