0

Good Morning All,

I'm having a small conceptual problem with ADO.NET EF4 (and perhaps ORM in general) and I was hoping someone could help fill in the gaps in my knowledge.

In my example I have a normalised Database with two Tables: User & Company

User // UserId(PK), CompanyId(FK), FirstName, LastName

Company // CompanyId(PK), CompanyName

I have created an Entity Data Model to match these tables in my application.

I now need to display a list of Users along with their Company Name in a listbox control. I realise I can display a list of Users using:

DatabaseEntities db = new DatabaseEntities();
Listbox1.ItemSource = db.Users;

Obviously the problem here is that it will display the CompanyId field as oppose to the CompanyName.

My question is; What is the best approach to get at the CompanyName Field? Do I create a stored procedure to return a different record set? Create a new entity with the fields I require?

I can think of several approaches but I'm not sure which is best practice.

Any help is greatly appreciated!

1 Answer 1

1

Figured it out, i wasn't aware you could specify bindings like:

<TextBlock Grid.Column="3" Padding="10,20,0,0" Text="{Binding Company.CompanyName}"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.