navigation-properties

How do I create a nested GridView bound to parent's EntityDataSource's navigation property?

<asp:FormView DataSourceId="edsAccounts"> <ItemTemplate> <asp:TextBox Text='<%# Eval("Email") %>' /> <asp:DataGrid ID="dgReports" DataSource='<%# Eval("Reports") %>'> </ItemTemplate> </asp:FormView> <asp:EntityDataSource ID="edsAccounts" runat="server" ConnectionString="name=Entities" DefaultContainerName="Entitie...

Including navigation properties from Entity Framework TPH classes

I've got an EF hierarchy that (dramatically simplified) looks something like this: class Room { EntityCollection<Session> Sessions; } class Session { EntityCollection<Whiteboard> Whiteboards; EntityReference Room; } class Whiteboard { EntityCollection<WhiteboardShape> WhiteboardShapes; EntityReference Session; } abstract class Whiteboar...

How to extract an individual item of an EntityCollection thru xaml binding?

Hi! I have a Contact entity that exposes a navigation proeprty for child Phone entities. Public Class Contact : Inherits EntityObject Public Property Phones() As EntityCollection(Of Phone) EndClass I want to Xamly retrieve the first phone of the bound contact. I tried the following but it doesn't work. Note: I also tried Phon...

Pluralization service in Entity Framework - Visual Studio 2008?

Does any one know if there is kinda implementation/addon for VS 2008 SP1 for pluralization service in entity framework like there is gonna b in vs 2010? example: In database: Entity Order ---OrderId ---CustomerId ---OrderDate Entity Customer ---CustomerId ---Name In EDM: Order.Customer Customer.Orders DataContext.Orde...

When querying with 'Include', does the EF checks if objects already exist in object state manager?

Should I avoid using Include in queries, or I can rely on the EDM that when it creates the query it excludes from the query items that already exist in the OSM? ...

Is EntityReference.Load checking for EntityReference.IsLoaded?

Hi I was wondering if EntityReference.Load method includes If Not ref.IsLoaded Then ref.Load() My question is basically: Dim person = Context.Persons.FirstOrDefault person.AddressReference.Load() person.AddressReference.Load() 'Does it do anything? ...

Delete a relationship?

What is the opposite of: Dim ad As New Address Person.AddressReference.Attach(ad) I mean how do I delete the Person.Address? (both with deleting and without - meaning only delete the relation)? ...

Undelete an entity marked as EntityState.Delete?

Hello, instead of talking let me talk with code: Dim Contact = Context.Contacts.Include("Phones") Dim phone = Contact.Phones(0) Contact.Remove(phone) How do I refresh the context now, canceling last relation deletion? I tried: Context.Refresh(RefreshMode.StoreWins, phone) 'Doesn't recover the relation Context.Refresh(RefreshMode.Sto...

Eager Loading on tracked items?

I have an element bound to an entity (Contact) that exposes some navigation properties. I want, that on some action (i.e. a "Load children" button), the Contact should load for all its children and grand children like I can do with an ObjectQuery.Include before the execution; example (pseudo): DirectCast(element.DataContext, Contact).S...

EF4 POCO one to many Navigation property is null

I'm using VS2010, EF4 feature CTP (latest release), and POCO objects, such as the example below: class Person { public int ID { get; set; } public string Name { get; set; } public virtual IList<Account> Accounts { get; set; } ... } class Account { public string Number { get; set; } public int ID { get; set; } ... } For the sak...

EF4 POCO - Updating a navigation property

I have a Recommendation object and a FeedbackLevel object and the FeedbackLevel object is a navigation property inside a Recommendation object Recommendation int EntityKey; FeedbackLevel Level; Inserting a new one works just fine with AddObject(). Here's what I'm trying with the update, which doesn't work. recommendation.Level = m...

Entity Framework: Why do navigation properties disappear after a group by?

I retrieve a collection with the following query: var numbers = _betDetailItem.GetBetDetailItems().Where(betDetailItem => betDetailItem.BetDetail.Bet.DateDrawing == resultToCreate.Date && betDetailItem.BetDetail.Bet.Status == 1).Where(condition); Right there I'm able to access my navigation properties and navigate through binded info....

Databinding exception with entity navigation property

I have two Entity classes: Order and OrderItem. Order contains a navigation property OrderItemSet of type System.Data.Objects.DataClasses.EntityCollection<OrderItem> On an aspx page is a FormView bound to this EntityDataSource: <asp:EntityDataSource ID="EntityDataSourceOrder" runat="server" ConnectionString="name=EntitiesContext...

Entity Framework. Updating EntityCollection using disconnected objects via navigation property.

I have a question, much liket this unanswered one. I'm trying to work with the entity framework, and having a tough time getting my foreign tables to update. I have something basically like this in the DB: Incident (table): -ID -other fields Responses (table): -FK:Incident.ID -other fields And and entities that match: Incident (entity...

Entity-Framework eagerly-load first item of a nav-property

Is there a way to make this code excute in one query with Entity-Framework? Private Sub LoadFirstPhone(vendor As Vendor) If Not vendor.ContactReference.IsLoaded Then _ vendor.ContactReference.Load(MergeOption.AppendOnly) vendor.Contact.Phones.Load(MergeOption.AppendOnly) End Sub I want two things: I want to be able...

Entity Framework POCO - Refresh a natvigation property

I am having some trouble with refreshing the related collection of entities. Essentially the problem is as follows: public class Student { public virtual ICollection<Lecture> Lectures { get; set; } public void AddLecture(Lecture lecture) { Lectures.Add(lecture); } public void CancelChanges() { ...

Implementing Navigation Properties in Entity Framework

Hey folks, I've been learning MVC 2 and I have pretty much everything understood except for the model part of things, I understand what the model is but actually implementing it has me confused. Here's my situation, I have my DB which has 3 tables; Ideas - table of ideas Tags - table of tags IdeaTag - link table connecting the above 2 ...