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
Solved

Entity Framework 4: how to populate a datasource

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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