views:

29

answers:

2

Hello guys,

i have 3 tables in my database and i created a entity model from database and it looks like this: alt text

what im trying to do is to bind all 3 tables to datagridview and im using a query like this

var result = from t in db.Transactions
                    from c in db.Categories
                    from a in db.Accounts
                    where t.FkCategoryID == c.CategoryID && t.FkAccountID == a.AccountID
                    select new { t.Description, t.BankReference, t.TransactionDate, c.CategoryName, a.AccountName, a.AccountNr };

this works well. But i need to be able to update the Transaction table by using the binding navigator toolbar

alt text

im not able to do that by using linq query and binding it to gridview.

Is there any way to accomplish that by using entity framework? I mean when i bind only one table to binding source im able to use that toolbar to delete update and add row but i have to show all tables and only be able to edit Transaction table

Thanks in advance

A: 

I don't think that this is possible because you are selecting annonymous type not the entity. So records in the grid are not related to your entity model. You have to handle record deletion and update by yourselves.

Ladislav Mrnka
A: 

One suggestion is to create a database view for your query and map to that instead of the joined tables.

Tim
i tryed that, the thing is that the view i've created is not updateable. is there any way to make it updateable in my case?
ilkin
You should be able to update views in SQL Server - what DB are you using? That said, I've never tried to map a view to entities.
Tim
i'm using mssql
ilkin