Questions tagged [entitycollection]

41 questions
7
votes
1 answer

What's the easiest way to sort an EF4 EntityCollection?

I'd love to add some sorting to an EntityCollection that is bound to an ItemsControl (in xaml). I'd also like to do it as simply as possible. It appears that this is not possible. If I wrap the collection in a "sorted" version of the collection…
user1228
6
votes
1 answer

Entity Framework - related ICollection getting materialized into HashSet

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…
Jefim
  • 2,877
  • 4
  • 29
  • 45
5
votes
3 answers

How to Sort WinForms DataGridView bound to EF EntityCollection

I'm trying to bind a WinForms DataGridView to an EntityCollection 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…
Adam Rackis
  • 79,454
  • 49
  • 255
  • 377
5
votes
3 answers

EntityFramework EntityCollection Observing CollectionChanged

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…
5
votes
3 answers

How do I get a Windows Forms DataGridView to show new records when bound to EntityCollection

Trying to add new records to the EntityCollection at runtime and have the the DataGridView update with the new information. I have tried bind the datagridview directly to the entity collection (i.e. ObjectSet) and through a BindingSource that is…
Jaime
  • 1,052
  • 2
  • 12
  • 26
5
votes
2 answers

Using OR condition in LINQ C#

I do write the following SQL query in LINQ c# SELECT max(creation_date) from TRS where approval_status='APPROVED' and transaction_type in ('Sale','PRE') I tried building below query on a list as follows var session = txns.Where(a =>…
DoIt
  • 2,788
  • 7
  • 38
  • 78
4
votes
2 answers

Linq to EF .Clear() does not clear

EntityCollection.ToList().Clear() Does not clear the entity collection. Any idea why? Any solution? How should i clear the EntityCollection?
ove
  • 2,814
  • 5
  • 28
  • 48
2
votes
1 answer

How to improve this code about EntityCollections?

This is the code which I'm not convinced. Please check how I'm passing as parameter the entity Collection. public ExamProduced GetExamProduced(XElement xml) { var examProduced = new ExamProduced { ExamProducedID =…
Darf
  • 2,217
  • 4
  • 19
  • 36
2
votes
2 answers

IEnumerable Any() with a simple int[]

Quick question: I'm comparing the IDs of entities in an EF4 EntityCollection against a simple int[] in a loop. I'd like to do something like: for (int i = 0; i < Collection.Count; ++i) { Array.Any(a => a.value == Collection[i].ID) ? /* display…
Major Productions
  • 5,522
  • 10
  • 63
  • 138
2
votes
1 answer

How can I set a many-to-many EntityCollection in Entity Framework efficiently?

When Entity Framework generates an ObjectContext for a two database tables (let's say Table1 and Table2) connected with a many-to-many relationship table, it doesn't create an object for the xref table, opting instead for collection properties on…
2
votes
1 answer

Adding to EntityCollection adds to the end of collection in Entity Framework?

I'm trying to have a View where the user can add items in a collection without having to go to a new View (the scenario is a sort of CV site where the user adds info about work experience, skills, etc, and it would seem absurd to go to a new View to…
Anders
  • 12,086
  • 23
  • 97
  • 148
2
votes
2 answers

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

Say I have the following entity: public class Post { public int Id { get; set; } public virtual ICollection Comments { get; set; } } When I retrieve a Post object from the database, I need to convert the Comments collection into an…
KallDrexx
  • 26,119
  • 31
  • 137
  • 246
2
votes
3 answers

Linq to entities - how to select entities with a where condition on their entitycollection?

I found several times people asking for the same question but it seems that the answer was never satisfying altough it should be pretty easy (in theory). Here is my question : I have an entity called "Company" inside which I have an entityCollection…
2
votes
0 answers

How to trigger the AssociationChanged event in EntityCollection?

I have to triggered the AssociationChanged event in EntityCollection, but i don't know the underlying collection type, i tried with object like below but the exception throws (source as…
2
votes
1 answer

Given an EntityCollection, how to find out whether it's owner is detached or not?

I need to find out, whether the owner of a given EntityCollection is detached from the Context or not. The reason is to avoid failing subsequent Load() calls to the collection. However, the _owner and _wrappedOwner field of the collection is not…
Marcel
  • 13,233
  • 18
  • 77
  • 130
1
2 3