IEnumerable is a list of (something) that have UserId as a property. LEt's say there are 3 (something) in the IEnumerable with UserId of value 100, 700 and 1500 .
What value do you think that is correct for the compiler to take when you say
Your suggestion works. Thanks, I have spent more time today ......
Where can I read more on Webmatrix IENumeables as nothing in the books I have on Webmatrix say anything about ElementAt(0) or including the Razor @ within a SELECT.
Does ElementAt(0) point only to the first object within dumptable1a?
Dallas
ReadOnlyCollection<object>
[0] = DynamicRecord
int MemberId = 101
int UserId = 111
string UserProfileEmail = "RandyPick
Enumerables don't belong to WebMatrix. They are .NET types which have a lot of methods: http://msdn.microsoft.com/en-us/library/system.linq.enumerable.aspx. They are a core
part of LINQ, so a book on LINQ would be a good starting point. Or any decent* C# book will cover them at a basic level
ElementAt() points to whichever object is at the position denoted by the index value you pass in. All C# collections have zero based indexes, so passing in 0 will return the first object of a collection. Another way to do it is to use the First or the FirstOrDefault
method:
var result = db.Query("Some SQL with a parameter @0", dumptable1a.First().UserId);
First brings back the item at index 0, or raises an exception if no items exit, whereas FirstOrDefault will bring back the item at index 0 or null if no items exist.
DMT20601
including the Razor @ within a SELECT
That isn't a "Razor" @. That is a C# @ sign used to denote a
verbatim string literal. It allows you to break a string over multiple lines without all that messy quotes and concatenation signs. Actually, my book does cover that, although it doesn't include any indepth discussion of LINQ.
*Buy a Professional C# book if you want to get one - not a "Beginning" type book.
It is odd that a variable (var) can be used to compare (WHERE) the results of an IEnumerable while the resulting objects of an IEnumberable cannot be used as easily. Thanks again for the reading suggestions, I'm off to the book store.
DMT20601
Member
86 Points
197 Posts
IENumberable is to much for the compiler.
Feb 22, 2013 12:53 AM|LINK
I working with Webmarix an the Starter Site
Compiler doesn't like the IENumberable dumptable1a
db.Query(Select ...) and db.QuerySingle(Select .. ) both fail the compiler.
Any ideas. Thanks
Dallas in Maryland.
Compiler Error Message: CS1061: 'System.Collections.Generic.IEnumerable<dynamic>' does not contain a definition for 'UserId' Line 33: "IsConfirmed, Password " + Line 34: "FROM Webpages_Membership " + Line 35: "WHERE Webpages_Membership.UserId = @0 ", dumptable1a.UserId); <--- error is here Line 36: Line 37: var grid1b = new WebGrid(dumptable1b); var dumptable1a = db.Query("SELECT MemberID, "+ "Userprofile.UserId, " + "Userprofile.email as UserProfileEmail " + "FROM Member " + "JOIN Userprofile " + " ON Member.UserId = Userprofile.UserId " + "WHERE Member.MemberId = @0 ", pullmember ); // @ObjectInfo.Print(dumptable1a); var grid1a = new WebGrid(dumptable1a); var dumptable1b = db.Query("SELECT UserId, CreateDate, confirmationToken, " + "IsConfirmed, Password " + "FROM Webpages_Membership " + "WHERE Webpages_Membership.UserId = @0 ", dumptable1a.UserId); <<- error hereignatandrei
All-Star
135057 Points
21659 Posts
Moderator
MVP
Re: IENumberable is to much for the compiler.
Feb 22, 2013 02:41 AM|LINK
IEnumerable is a list of (something) that have UserId as a property. LEt's say there are 3 (something) in the IEnumerable with UserId of value 100, 700 and 1500 .
What value do you think that is correct for the compiler to take when you say
?
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: IENumberable is to much for the compiler.
Feb 22, 2013 04:43 AM|LINK
var dumptable1b = db.Query(@"SELECT UserId, CreateDate, confirmationToken, IsConfirmed, Password FROM Webpages_Membership WHERE Webpages_Membership.UserId = @0", dumptable1a.ElementAt(0).UserId);Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
DMT20601
Member
86 Points
197 Posts
Re: IENumberable is to much for the compiler.
Feb 22, 2013 04:47 AM|LINK
}DMT20601
Member
86 Points
197 Posts
Re: IENumberable is to much for the compiler.
Feb 22, 2013 05:03 AM|LINK
Your suggestion works. Thanks, I have spent more time today ......
Where can I read more on Webmatrix IENumeables as nothing in the books I have on Webmatrix say anything about ElementAt(0) or including the Razor @ within a SELECT.
Does ElementAt(0) point only to the first object within dumptable1a?
Dallas
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: IENumberable is to much for the compiler.
Feb 22, 2013 06:42 AM|LINK
Enumerables don't belong to WebMatrix. They are .NET types which have a lot of methods: http://msdn.microsoft.com/en-us/library/system.linq.enumerable.aspx. They are a core part of LINQ, so a book on LINQ would be a good starting point. Or any decent* C# book will cover them at a basic level
ElementAt() points to whichever object is at the position denoted by the index value you pass in. All C# collections have zero based indexes, so passing in 0 will return the first object of a collection. Another way to do it is to use the First or the FirstOrDefault method:
var result = db.Query("Some SQL with a parameter @0", dumptable1a.First().UserId);First brings back the item at index 0, or raises an exception if no items exit, whereas FirstOrDefault will bring back the item at index 0 or null if no items exist.
That isn't a "Razor" @. That is a C# @ sign used to denote a verbatim string literal. It allows you to break a string over multiple lines without all that messy quotes and concatenation signs. Actually, my book does cover that, although it doesn't include any indepth discussion of LINQ.
*Buy a Professional C# book if you want to get one - not a "Beginning" type book.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
ToughMan
Participant
1490 Points
635 Posts
Re: IENumberable is to much for the compiler.
Feb 22, 2013 09:12 AM|LINK
This is an interface that will let you do a "inner loop" by only exposing a public method called "GetEnumerator()".
U can implement this interface by inheriting it and using "yield return".
What's more——u can also have another very very important class called "Enumerable", there are many extended methods there.
DMT20601
Member
86 Points
197 Posts
Re: IENumberable is to much for the compiler.
Feb 22, 2013 04:41 PM|LINK
It is odd that a variable (var) can be used to compare (WHERE) the results of an IEnumerable while the resulting objects of an IEnumberable cannot be used as easily. Thanks again for the reading suggestions, I'm off to the book store.
As always, the knowledge queue continues ...