Solved

Entity Framework 4: how to populate a datasource

Posted on 2010-11-17
1
586 Views
Last Modified: 2013-11-26
Using EF4, how do I populate a datasoure for a drop down list using the entity framework?

            Dim personQuery As ObjectQuery(Of Person) = _
                From p In personContext.People.Include("Office") _
                Order By p.Name _
                Select p

                ddlDepartmentList.DataSource = CType(personQuery, ObjectQuery).Execute(MergeOption.AppendOnly)

Open in new window


Is that right?
0
Comment
Question by:Starr Duskk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 34161090
You have a little too much going on there, and it can be pared down to something like this:

           
           Dim personQuery = _
                From p In personContext _
                Order By p.Name _
                Select p

                ddlDepartmentList.DataSource = personQuery
                ddlDepartmentList.DataBind()

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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