linq-to-entities

Multi-Database Transactional System & ASP.NET MVC

So I have a challenge to build a site that people online can use to interact with organizations.: http://stackoverflow.com/questions/1691058/asp-net-mvc-customer-application One of the requirements is financial processing and accounting. I'm very comfortable using SQL Transactions and stored procedures to do this; i.e. CreateCustomer a...

Best way to check if object exists in Entity Framework?

What is the best way to check if an object exists in the database from a performance point of view? I'm using Entity Framework 1.0 (ASP.NET 3.5 SP1). ...

Can I do this with an IQueryable<T> ?

Hi folks, is it possible to add an extension method to IQueryable<T> and then, for my Linq2Sql or EF or NHibernate or LinqToObjects, define it's functionality / how each repository will impliment this method / translate this method to some sql? For example, imagine I want the following :- var result = (from q in db.Categories() ...

What is equivalent GetPropValue<T> method in L2E ?

Hi people. I´m have a problem using EF for my data model. I have this code in my method: listaPaginada = sortOrder.Equals("asc") ? _cadastroServ.SelecionaNotasFiscais(idParceiro).OrderBy(i => i.GetType().GetProperty(query)) : _cadastroServ.SelecionaNotasFiscais(idParceiro).OrderByDescending(...

Need help with designing a query in ELinq

This is my query: Dim vendorId = 1, categoryId = 1 Dim styles = From style In My.Context.Styles.Include("Vendor") _ Where style.Vendor.VendorId = vendorId _ AndAlso (From si In style.StyleItems _ Where si.Item.Group.Category.CategoryId = _ categoryId).Count > 0 _ ...

Extension Methods in Linq to entity-expressions

Hi, If I create an extension method for my entity objects and try to use it in a LINQ-expression I get an error. Is this a limitation and something I cant do or am I missing something? regards Freddy ...

asp.net mvc and linq to entities: how to test model custom binding?

I'm trying to build a test for my custom model binder, but not having any success. The call to base.BindModel always returns a null. Is there a way to test custom binding when using LINQ to Entities? foo in this case is a table in the db with two fields - a numeric and a text value. fooBinder.cs: public override Object BindModel(Con...

How do you add a primary key to a sql view? - Or alternate way to link views to linq-2-entities

I'm adding a very simple view (or trying to) to my entities object model. The database is in sql server 2008. I'm on .net 3.5 (sp1) using C#. The view has two fields: color and colorcount, a Varchar(50) and a count(*) respectively. When I do Update Model from Database, and select the view to add, it runs (it updated tables, adding ...

linq to entities, operator like WhereAnyIn?

I saw whereIn implementation before. But I'm wondering can someone show me to write a opration "WhereAnyIn". for example: Ive an entities: Post --- PostTag --- Tag I need a query with parameter int[] tagids, which where fetch all posts that has any of tagid in the given list. I cannot figure it out . thanks for your help. ...

Read only Search function. Stored Procedures or IQueryable with POCOs and Ef 4.0

We have some search functionality that can return tens of thousands of results from the db although it will only fetch the rows needed to be displayed into e.g. first 10 records. When the next page is requested, we hit the db again. It searches our database based on a set of variables and this search can then be refined which will resul...

LINQ to Entities - "Including" a complex object while also grouping

I have a set of tasks that I need to select distinct on (group by in L2E). Those tasks have a referenced property, "Activity" that I need to be loaded so that I can reference the task.Activity object. In the first example below, this works fine. However, when I group by the description, the activity does not get loaded. What am I mis...

Entity Framework: Inserting new entity associated with another entity

I have two tables FilesystemEntries and CacheEntries where there is an association of 0..1 CacheEntry per FilesystemEntry (that is a FilesystemEntry can have a null CacheEntry, but not vice-versa). Initially, the CacheEntry for all FilesystemEntries is null. I'm having trouble changing this (adding a new CacheEntry). The code (truncated)...

How can I search into database with WPF and Linq-to-entities model

Hello, I prepare a WPF project, where I want to implement a more complex search. I use LINQ to entities through the ADO.NET Entity model and plan to do the display in WPFToolkit DataGrid. My search window should allow search by a few different criteria. My idea is to be able to write in (for example) name, surname and occupation textbo...

Difference between LINQ to Entities with and without ObjectResult

I have the following LINQ to Entities query... var results = from c in context.Contacts select c; which works fine in returning a collection of contacts. But I have seen sample code that does this instead... ObjectResult<Contact> results = (from c in context.Contacts select c).Execute();...

How should I separate entities methods ?

Good people of SO, Today I have some serious concerns on my business layer design. It is based on Entity POCO objects and I want to add logic to these entities BUT, there are 2 types of logic: Pure C# logic Persistence logic (LinqToEntities in my case) My question is simple: How should I separate these two kinds ? First, I was thi...

LINQ to Entity - Join between 3 tables 1 to many -> many to 1

Hey all, I'm a begginer with LINQ to Entity. I'm trying to select a record to update it with user entries later. Here's my schema I'm trying to get a prediction record and I just can seem to make the query work. Is it a problem with the way my tables are built or something... I'm really lost here? Here's my query var query = (fro...

Exceptions and Linq to Entities

I have a tough question to ask so please bier with me. In this code below, this works because the programmer was interested in projecting only the specific errors caused by the physical data-layer to the eventlog. The rest are pushed farther up the stack. This is specifically because he is able to catch OdbcException(s). I am impleme...

Sort child objects while selecting the parent using LINQ-to-Entities

Imagine you've got some Entity Framework entities that look like this (obviously not these specific classes, but the autogenerated ones with all the Entity Framework plumbing; these are just for illustration): public class Parent { public int ID { get; set; } public List<Child> Children { get; set; } } public class Child { ...

Which ORM tools support this version of Queryable.Select extension method

Do you know an ORM supporting this extension method: public static IQueryable<TResult> Select<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, int, TResult>> selector) Basically, it allows to add row number (index of result in sequence) to the projection. Example of its usage with IEnumerable is here. ...

Entity Framework: is there a complete list of supported IQueryable extension methods?

I'm looking for this list for Entity Framework. Ideally, I'd like to have a list of other supported methods (or members - e.g. constructors), e.g. for DateTime type. ...