Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2014, 01:43 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Default get list of genre reviews from business layer

Hello Imar,
you have shown how we can create anonymous types and bind them to data bound controls.
like this
Code:
Using myDatabaseContext As DataContext = New DataContext()

            Dim favGenres = From a In myDatabaseContext.Genres_
                    Order By a.Name _
                    Select New With {a.Name, a.Reviews}

            Repeater1.DataSource = favGenres
            Repeater1.DataBind()

End Using
but how do I return the same result if put this code into a separate class library. I can not return anonymous type.

Can you please give me code for the same.

Thanks
 
Old March 31st, 2014, 07:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Sophia,

You can't pass anonymous objects back from a function; they only exist within the context (like a function) you define them in.

You can create a class that has the same field as your anonymous object and return an instance of that class instead. At the end of the function, you create an instance of this new class, and then copy over the fields from the anonymous object into your new class.

Hope this helps,

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!
 
Old April 4th, 2014, 11:49 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Thanks Imar, for shedding light on the topic.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Transparent Business Layer pinch BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 February 17th, 2008 02:19 AM
Do we need Business Logic Layer.vb files? cJeffreywang ASP.NET 2.0 Professional 12 January 12th, 2008 06:28 AM
Handle Transactions from Business Logic Layer sonishpaul ASP.NET 2.0 Professional 1 December 3rd, 2007 05:52 AM
Question about Business Layer hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 March 21st, 2005 06:49 PM
Errors in a business layer bmains ASP.NET 1.x and 2.0 Application Design 1 February 11th, 2005 02:27 PM





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