hi,
here's a description of the code with the problem:
DB.MainDataContext context = new DB.MainDataContext();
var sections = from s in context.Sections orderby s.Title select s;
foreach(var section in sections){
*var place = from p in context.Places where p.SectionId == section.Id orderby p.Title select p;
if ( *place. ?
first potential problem/question (*) can I use "var" inside a foreach loop?
isn't it a problem?
* the main problem: when typing "place." (which is the linq object) the intellisense does'nt display all the property fields existing in "place".
it was supposed to popup. so I understand that something with the declarations I've made is wrong, because visual studio doesn't recognize "place".
does anyone got a clue ?
thanks in advanced.
Shahar Weinstein.
strange problem using dotconnect
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
You should be able to use the 'var' keyword inside loops. The 'var' keyword only means that you leave determining the exact type of the variable for the compiler.
As for the 'place' properties, the problem is that the variable you've declared is of type 'IQueryable', not 'Place' itself. I.e., it is a collection and thus the members Intellisense show you are properties and methods of the collection type. To work with the object of the Place type, you should enumerate the collection. E.g., you can use
Please tell us if this helps.
As for the 'place' properties, the problem is that the variable you've declared is of type 'IQueryable', not 'Place' itself. I.e., it is a collection and thus the members Intellisense show you are properties and methods of the collection type. To work with the object of the Place type, you should enumerate the collection. E.g., you can use
Code: Select all
var firstPlace = place.FirstOrDefault();