linq-to-entities

Entity Framework - One to One relationship, how to save record

I have a one-to-one relationship on two tables with are represented by 2 classes in my EDM. I am trying to save a new record and am confused how to save to the second entity. I have tried the following. Dim myObject as new MyObject myObject.prop1 = 5 myObject.prop2 = "Test" myObject.myOtherObject.prop1 = 3 myObject.myOtherObject.pro...

LINQ to Entities for SQL Server and Oracle

Can I write the same queries (select, insert, update etc.) in LINQ to Entites that will be validate for SQL SERVER and Oracle database? I thinking that if I write now query for SQL SERVER, it will be ok for future Oracle db...? It's exist pattern which provide interface for something like that ? ...

How can you increase timeout in Linq2Entities?

I'm doing a basic select against a view. Unfortunately the result can be slow and I'm getting timeout errors intermittently. How can I increase the timeout? Using .NET 3.5, Sql Server 2000, Linq2Entities I'm using the very basic query List<MyData> result = db.MyData.Where(x.Attribute == search).ToList(); Fixing the query so that it'...

Linq to Entity Left Outer Join

Hi All, I have an Entity model with Invoices, AffiliateCommissions and AffiliateCommissionPayments. Invoice to AffiliateCommission is a one to many, AffiliateCommission to AffiliateCommissionPayment is also a one to many I am trying to make a query that will return All Invoices that HAVE a commission but not necessarily have a related...

Linq to Entities Join -- I don't want anonymous types

I have two tables ('keywords', 'titles') that are related via a mapping table. I am trying to return a list of Map_Keywords_Title (the mapping table's object) based on the results of a join. Until I added the last part with typedQuery it was just returning objects of anonymous type. I want it to return items of type 'Map_Keywords_Title...

Binding Linq To Entities query results to a datagridview

I just started playing with Linq to entities in a windows forms application and am not understanding one behavior that looks so simple though. If i type code below, i get ReadOnly records in my dataGridView Dim x = From n in Table1 _ Select n.FirstName, n.LastName, N.Department DataGridView1.DataSource = x But if i type the ...

Entity framework (3.5): How to translate a certain LINQ query to eSQL?

Hi there, I have the following LINQ query that I need to translate to Entity SQL /eSQL): return (ObjectQuery<User>) from user in Users where !user.Roles.Any(r => r.AnIntegerProperty < 0) select user; User.Roles is an navigation property to the n:m relation to Roles and there also is a Role.Users navigation property the other wa...

Linq : problem with primary key

I get the following error message The table/view 'TABLE1' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity you will need to review your schema, add the correct keys and uncomment it when I try to add a view to an Entity Data Model. For ...

Why do LINQ to Entities does not recognize certain Methods?

Why cant I do this: usuariosEntities usersDB = new usuariosEntities(); foreach (DataGridViewRow user in dgvUsuarios.Rows) { var rowtoupdate = usersDB.usuarios.Where( u => u.codigo_usuario == Convert.ToInt32(user.Cells[0].Value) ).First(); rowtoupdate.password = user.Cells[3].Value.ToString(); } usersDB....

Is there a way to make Linq to Entities map unrecognized methods/functions to MySql functions?

Is there a way to make Linq to Entities map unrecognized methods/functions to MySql functions? I want to add support to some functions like Convert.* ...

Entity Framework: Delete Object and its related entities

Hi, Does anyone know how to delete an object and all of it's related entities. For example i have tables, Products, Category, ProductCategory and productDetails, the productCategory is joining table of both Product and Category. I have red from http://msdn.microsoft.com/en-us/library/bb738580.aspx that Deleting the parent object also d...

Entity Framework 4 / POCO - Where to start?

Hi, I've been programming for a while and have used LINQ-To-SQL and LINQ-To-Entities before (although when using entities it has been on a Entity/Table 1-1 relationship - ie not much different than L2SQL) I've been doing a lot of reading about Inversion of Control, Unit of Work, POCO and repository patterns and would like to use this m...

Defaultifempty seems to work in linq to entities

I'm new to linq and linq to entities so I might have gone wrong in my assumptions, but I've been unknowingly trying to use DefaultIfEmpty in L2E. For some reason if I turn the resultset into a List, the Defaultifempty() works I don't know if I've inadvertantly crossed over into Linq area. The code below works, can anyone tell me why? ...

Is looping through the entityreference the correct way?

I want to get all users that have a specific role to a list of usernames. Is using .Include to include all the users, and going through the UsersReference the best way to loop through all the users that are associated with the role? I noticed I could not do a foreach(User user in role.Users) but UsersReference seem to work, but is that...

Linq to Entities and LEFT OUTER JOIN issue with MANY:1 relations

Can somebody tell me, why does Linq to Entities translate many to 1 relationships to left outer join instead of inner join? Because there's referential constraint on DB itself that ensures there's a record in the right table, so inner join should be used instead (and it would work much faster) If relation was many to 0..1 left outer joi...

How can I use a stored procedure in Entity FrameWork where I need 2 or more entities columns together?

How can I use this stored procedure in Entity Framework? I need to call it from like that : foreach (SalesOrderDetail order in objCtx.GetOrderDetails(soHeaderNumber)) Console.WriteLine("Header#: {0} " + "Order#: {1} ProductID: {2} Quantity: {3} Price: {4}", ...

Linq to Entities - left Outer Join

Could you please help me to figure this one out? I need to replace a join with OSLP table with OUTER join. Seems a bit tricky for someone who is not an expert in Linq to entities. How would I do that? var surgeonList = ( from item in context.T1_STM_Surgeon .Include("T1_STM_SurgeonTitle") .Include("OTER") where it...

Advanced Linq query using into

I have this query that someone else wrote, it's over my head so I'm looking for some direction. What is happening currently is that it's taking numbers where there is a goal and no history entered, or history and no goal, this screws up the calculations as both goal and history for the same item are required on each. The three tables ...

LINQ to Entity, using a SQL LIKE operator

I have a LINQ to ENTITY query that pulls from a table, but I need to be able to create a "fuzzy" type search. So I need to add a where clause that searches by lastname IF they add the criteria in the search box (Textbox, CAN be blank --- in which case it pulls EVERYTHING). Here is what I have so far: var query = from mem in contex...

Can we control LINQ expression order with Skip(), Take() and OrderBy()

I'm using LINQ to Entities to display paged results. But I'm having issues with the combination of Skip(), Take() and OrderBy() calls. Everything works fine, except that OrderBy() is assigned too late. It's executed after result set has been cut down by Skip() and Take(). So each page of results has items in order. But ordering is done...