entitycollection

Entity Framework - related ICollection getting materialized into HashSet

柔情痞子 提交于 2019-12-21 04:52:29
问题 I use EntityFramework POCO + proxies + lazy loading in my project. Today I was pretty surprized to see that the class Transaction has its related collection Rows materialized into HashSet (instead of EntityCollection ). I need EntityCollection for tracking changes in the collection. public class Transaction { public virtual ICollection<TransactionRow> Rows { get; set; } } However other entity classes have their related collection materialized into EntityCollection . I am loading the

How to Sort WinForms DataGridView bound to EF EntityCollection<T>

僤鯓⒐⒋嵵緔 提交于 2019-12-18 05:04:29
问题 I'm trying to bind a WinForms DataGridView to an EntityCollection<T> from an EntityFramework4 object. The trouble is, I can't figure out how to get it to sort (automatically). All I'm doing is setting the BindingSource's DataSource property to the entity's collection. MyBindingSource.DataSource = CurrentItem.InvoiceNotes; I really hope there's a simple configuration I can add to this to get it to work; I really don't want to have to wrap my EF Collection in a new BindingList container. 回答1:

How can I convert an EF4 Code-First ICollection to an EntityCollection?

孤街醉人 提交于 2019-12-08 01:52:36
问题 Say I have the following entity: public class Post { public int Id { get; set; } public virtual ICollection<Comment> Comments { get; set; } } When I retrieve a Post object from the database, I need to convert the Comments collection into an EntityCollection<T> so that I can check some EF4 related data about the collection, such as if the data was eager loaded or not. Unfortunately, if I try to do a direct cast from ICollection<T> to EntityCollection<T> , I get an exception due to the fact

Returning a collection of objects where an objects property matches any property from another collection of objects using LINQ-to-Entities

*爱你&永不变心* 提交于 2019-12-07 19:21:06
问题 I've been searching all day and can't find a solution to this... I have an EntityCollection of Communication objects which each have an instance of an Intention object(one-to-one). I also have a User object which has many instances of UserLocation EntityObjects (one-to-many) Intention objects have a property UID . UserLocation objects have a property LID . I want to write a LINQ expression which returns all Communication objects where the UID property of the Intention instance associated to a

EntityFramework EntityCollection Observing CollectionChanged

房东的猫 提交于 2019-12-07 04:03:47
问题 I'm using EntityFramework database first in an application. I would like somehow to be notified of changes to an EntityCollection in my ViewModel. It doesn't directly support INotifyCollectionChanged (why?) and I haven't been successful in finding another solution. Here's my latest attempt, which doesn't work because the ListChanged event doesn't appear to get raised: public class EntityCollectionObserver<T> : ObservableCollection<T>, INotifyCollectionChanged where T : class { public event

Returning a collection of objects where an objects property matches any property from another collection of objects using LINQ-to-Entities

こ雲淡風輕ζ 提交于 2019-12-06 08:59:05
I've been searching all day and can't find a solution to this... I have an EntityCollection of Communication objects which each have an instance of an Intention object(one-to-one). I also have a User object which has many instances of UserLocation EntityObjects (one-to-many) Intention objects have a property UID . UserLocation objects have a property LID . I want to write a LINQ expression which returns all Communication objects where the UID property of the Intention instance associated to a Communication object equals ANY LID property of ANY instance of a UserLocation instance for a User

EntityFramework EntityCollection Observing CollectionChanged

て烟熏妆下的殇ゞ 提交于 2019-12-05 09:37:56
I'm using EntityFramework database first in an application. I would like somehow to be notified of changes to an EntityCollection in my ViewModel. It doesn't directly support INotifyCollectionChanged (why?) and I haven't been successful in finding another solution. Here's my latest attempt, which doesn't work because the ListChanged event doesn't appear to get raised: public class EntityCollectionObserver<T> : ObservableCollection<T>, INotifyCollectionChanged where T : class { public event NotifyCollectionChangedEventHandler CollectionChanged; public EntityCollectionObserver(EntityCollection<T

How to Sort WinForms DataGridView bound to EF EntityCollection<T>

独自空忆成欢 提交于 2019-11-29 07:30:47
I'm trying to bind a WinForms DataGridView to an EntityCollection<T> from an EntityFramework4 object. The trouble is, I can't figure out how to get it to sort (automatically). All I'm doing is setting the BindingSource's DataSource property to the entity's collection. MyBindingSource.DataSource = CurrentItem.InvoiceNotes; I really hope there's a simple configuration I can add to this to get it to work; I really don't want to have to wrap my EF Collection in a new BindingList container. Marc Gravell To support sorting, the source needs to implement IBindingList with sorting enabled. Annoyingly,