Solved

Entity Framework 4: how to populate a datasource

Posted on 2010-11-17
1
577 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:BobCSD
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now