Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 9th, 2015, 04:13 PM
Authorized User
Points: 322, Level: 6
Points: 322, Level: 6 Points: 322, Level: 6 Points: 322, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
Default Getting query result LINQ

Hi
I'm trying to get the result of a view (called view_users) and then I want to go through the result (for each next) to send an email (for example).
Depending on the situation (if then), I want to get all users or only those with view_users.name is "Brown".
How do I declare this? I'm having troubles doing this.
Hope you can help.
Alex
Reply With Quote
  #2 (permalink)  
Old September 9th, 2015, 04:21 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Isn't this what you already have in the code in the other thread (about the Count). Which part are you having troubles with?

Also, since this is not directly related to the book, please consider posting this in the General category here: http://p2p.wrox.com/asp-net-asp-12/

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old September 9th, 2015, 04:30 PM
Authorized User
Points: 322, Level: 6
Points: 322, Level: 6 Points: 322, Level: 6 Points: 322, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
Default

No, it's not the same and I think it's related to the book.
I probably did not explain well.
I have a view with users. I would like to get the data of all users or of those based on a condition (let's say by name "brown"). In the "count" example, I could declare the Users as integer.
But now I don't want to get the number of users, I want to get the columns of the users. How do I do this with LINQ?

Dim users as ???
Using myentities As New entity
If x=1 then
Dim users = (From r In myentities.users select r) 'Get data of all users
else
Dim users = (From r In myentities.users where r.name=N'Brown' select r) 'Get data of users named Brown
end if
for each user in r
next

What is wrong?
Thanks for your help.
Reply With Quote
  #4 (permalink)  
Old September 10th, 2015, 03:21 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

>> No, it's not the same and I think it's related to the book.

Well, yes and no. It's related to the book since it deals with ASP.NET and LINQ. However, it's not directly related since your question doesn't deal with any of the text, exercises or code examples directly. If you post in the General category, you'll attract more visitors and are likely to get an answer faster.

Anyway, to discover the type, hover your mouse over Dim or users (I forgot where it shows up for VB). You'll likely see something like IQueryable Of user which will be the type that you need in your Dim statement.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LINQ Query returning only 1 record digink BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 May 24th, 2010 12:50 PM
LINQ Query modification jsymons BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 12 October 14th, 2009 04:46 PM
How to get access to value in LINQ query result StevenF ASP.NET 3.5 Basics 6 May 12th, 2009 05:46 AM
Binding IEnumerable result set of a LINQ query prakashbpl .NET Framework 3.5 0 November 11th, 2008 04:41 AM
Using LINQ, with BeerHouse /Instant Result Project SoftMind BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 June 21st, 2007 03:08 AM



All times are GMT -4. The time now is 04:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.