Solved

Entity Framework 4: how to populate a datasource

Posted on 2010-11-17
1
589 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

615 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