Solved

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

Posted on 2012-03-12
4
765 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
4 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
Comment Utility
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 39

Expert Comment

by:Kyle Abrahams
Comment Utility
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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
 

Author Closing Comment

by:Alyanto
Comment Utility
Bloody marvelous, thank you
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now