entityset

LINQ-to-SQL + One-to-Many + DataBinding deleting problem

I use LINQ-to-SQL to load data from a database that has two tables in a one-to-many relationship (one Recipe has many Ingredients). I load a Recipe and LINQ retrieves Ingredient objects into an EntitySet that is binded into a ListBox. If I want to delete some Ingredients off a Recipe, I get a "An attempt was made to remove a relationsh...

Struggling with .ToList() returing an EntitySet<...>, not an IList<..>

Hi folks, I'm trying to retrieve a list of Id's from a collection that is a few levels deep in an object heirachy. When i try to do a ToList(), I keep getting an EntityList<> retrieved instead .. which means it's not allowing me to retrieve an instance's BarId property because the EntitySet is a Enumerable, not a single instance object....

How do you sort an EntitySet<T>

The MSDN documentation states that an EntitySet implements IBindingList (see 'Binding to EntitySets' at http://msdn.microsoft.com/en-us/library/bb546190.aspx) However, it can be clearly seen that an EntitySet does not implement this interface! So how do I sort? For context, I'm binding this set to a WPF ListView. For wider context o...

WPF binding not notifying of changes

I have a WPF sorting/binding issue. (Disclaimer: I am very new to WPF and databinding so apologise if I am asking a really dumb question :-)) Firstly, I have a linqToSql entity class Contact with an EntitySet<Booking> property Bookings on it. If I directly bind this Bookings property to a ListView, the application seems to correctly no...

Linq and ObservableCollection

Hello everybody, I have a problem with Linq and ObservableCollections in my WPF application. Context of the problem: I've created a very simple SQL database with two tables: User and BankAccounts. The User Table has an one-to-many relationship with the BankAccounts Table. Next I've created Linq-to-SQL dataclasses, which worked fine ==...

ASP.NET MVC Model Binding Related Entities on Same Page

This problem has been driving me crazy for several hours now... In my domain, I have 2 entities that are related to each other Sku and Item. Each sku can have many items. public class Sku { private readonly EntitySet<Item> items; public Sku() { items = new EntitySet<Item>(AttachItems, DetachItems); } public...

Datagridview with sorted EntitySet<T>? (.NET 3.5)

I'm hoping there's a simple answer to this one I've missed in hours of Googling... I have a DataGridView which needs to display and add/delete/edit records from a database. I'm using the Entity Framework, so records are initially EntitySet. Attempt One BindingSource has facilities for sorting, but oh... they don't seem to actually ...

DeleteOnNull Error

I've got a set of DB objects sitting in an EntitySet on my main object definition. This handles additions and updates fine, but I found the removing items from the list didn't result in the database records being deleted, so I had to create a method in the data repository object to delete the records as the data object doesn't have acce...

EntitySet Querying

I'm trying to run a query similar to var results = MyItem.MyEntitySet.Where( x => x.PropertyB == 0 ) MyEntitySet has one association, PropertyA, with MyItem. Ideally, the underlying SQL query should be SELECT .. FROM .. WHERE ([t0].[PropertyA] = @p0) AND ([t0].[PropertyB ] = @p1) since PropertyA and PropertyB are the two primary ...

LINQ to SQL: EntitySet<T>.Assign

I have many-to-many relationship in LINQ to SQL scheme: Products table, Categories table and ProductCategories table (ProductId, CategoryId fields). Product prod; EntitySet<Category> cats = prod.ProductCategories; Now I have a list of category ids (catIds) and I want to set (overwrite) them as categories of a single product in one ope...

non-public members in EntitySet

Hi, I am trying to get access to the property Schema in EntitySet but it is non-public. How do you get access to Schema. Thanks Rich ...

MVC 1.0 + EF: Does db.EntitySet.where(something) still return all rows in table?

In a repository, I do this: public AgenciesDonor FindPrimary(Guid donorId) { return db.AgenciesDonorSet.Include("DonorPanels").Include("PriceAdjustments").Include("Donors").First(x => x.Donors.DonorId == donorId && x.IsPrimary); } then down in another method in the same repository, this: AgenciesDonor oldPrimary = this.FindPrimar...

Linq to SQL EntitySet Binding the MVVM way

Hi everybody! In a WPF application i'm using LINQ to SQL classes (created by SQL Metal, thus implementing POCOs). Let's assume i have a table User and a Table Pictures. These pictures are actually created from one picture, the difference between them may be the size, coloring,... So every user may has more than one Pictures, so the a...

MVC Entity Framework state behavior with multiple instances of an entityset

I'm trying to understand the relationship between entityset instances of an EF Entities model (the model was created by Entity Designer). Basically I end up with 1 logical transaction having 2 instances of an entity's Repository class. Data committed successfully (confirmed by direct SSMS query to SQLServer) in one instance does not be...

ASP.NET MVC - Submit Form with complex Model with EntitySet

Hello There, I'm struggling myself trying to make my form work with my models... So, I have 3 Models Account has_one -> Company has_many -> Individuals -> has_one Document So the account can have one company and many individuals with one document each. When submit my forms I have the following action [AcceptVerbs(HttpVerbs.Pos...

Using Linq to select a list of Entities, linked Entities, linked Entities

Apologies for the poor question title - I'm not sure how to describe what I'm doing but that is the best I could come up with, please edit it if what I'm asking for has a real name! I have Programmes, which can have a group of Projects assigned, which in turn have groups of Outputs assigned. I would like to get all the outputs for the ...

DomainContext, Silverlight 3, code behind, Edit EntitySet

I'm trying to get my brain wraped around Silverlight RIA I'm to a point where I can create an object with a collection of objects which also has a collection of objects. Test object that holds test questions, that holds question answers. I have the associations set up and the the data makes it to to silverlight app. So in my loaded c...

HowTo update/modify LINQ EntitySet?

In my LINQ to SQL generated classes I have some classes containing EntitySets. Everything looks great until I need to modify the EntitySet (add, delete some relationships). I thought that it was going to work doing something like: User.Actions = newUserActions; //This is how I used it with NHibernate Then when I try to submit chang...

RIA Services EntitySet does not support 'Edit' operation

Hello everbody! Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created an EF Model (no POCOs), generic repository on top of it and a RIA Service(hosted in an ASP.NET MVC application) and tried to get data from within the ASP.NET MVC application: worked well. Next step: Silverlight client. Got a refe...

ASP.NET MVC/LINQ: What's the proper way to iterate through a Linq.EntitySet in a View?

OK so I have a strongly-typed Customer "Details" view that takes a Customer object Model. I am using LINQ to SQL and every Customer can have multiple (parking) Spaces. This is a FK relationship in the database so my LINQ-generated Customer model has a "Spaces" collection. Great! Here is a code snippet from my CustomerRepository where ...