linq-to-entities

LINQ to Entities: Why can't I use Split method as condition?

Hi, I have the following LINQ query: var aKeyword = "ACT"; var results = from a in db.Activities where a.Keywords.Split(',').Contains(aKeyword) == true select a; Keywords is a comma delimited field. Everytime I run this query I get the following error: "LINQ to Entities does not recognize the method 'Boo...

Linq to Entities simple group query

How to write (simple) LINQ to Entities query that groups elements by some attribut and count them? SELECT answernumber, count(answerID) FROM answers WHERE questionID = id GROUB BY answernumber ORDERBY answernumber; That should be simple but i don't know how to write it. ...

How can I perform this query using L2E?

Hi, I have a 2 tables: Activities ActivityKeywords ********** **************** ID --> ActivityID Name Keyword I need to return all activities that match a specific keyword. ...

Cast linq results to List<MyInterface>

Hi, I have extended my entities to implement specific interfaces for its type. I am trying to perform the following query: var results = from x in context.MyEntityTable where x.AProperty == AValue select x; return results.Count() > 0 ? results.Cast<IApplicationEntity>().ToList() : null; However, I kee...

Adding behavior to LINQ to Entities models

What's the preferred approach when using L2E to add behavior to the objects in the data model? Having a wrapper class that implements the behavior you need with only the data you need using (var dbh = new ffEntities()) { var query = from feed in dbh.feeds select new FFFeed(feed.name, new Uri(feed....

How to query associations in Linq to Entity framework in .NET Ria Services

I have just started with Linq and Linq to Entity Framewok. On top of that with the .NET Ria services. My problem is that I have 2 tables Folder and Item with a many to many relationsship using a third "connection" table FolderItem like this: In the .NET RIA Service domain service, I want to create a method that returns all Items for ...

LINQ to Entities and grouping with many-to-many association.

I have a Product and Category entity in many-to-many association. I am trying to display the category count for each product. So far, I have come up with this: Dim context = new Context() Dim products = context.Products() Dim productsByCategoryCount = From product In Products Group product By productId = product.productId Into produc...

How to sort this Repository pattern and ASP.Net website architecture ?

I am Creating a new ASP.Net website "not mvc", and willing to make the data access layer has 2 versions, one using the Linq to Sql and another one using ad.net entity framework. Note: kigg is doing the same but in MVC website and too complex than i want. I learned that the best pattern to achieve my goal is using repository design patter...

MySql and Entity framework randomly gives Schema specified is not valid error

I'm using Entity Framework to access my MySQL database. The model was generated using EDMGEN2 and everything works great. I can do all my linq-to-entity query goodness... ...until an indeterminate amount of time passes and I get "The ProviderManifestToken '5' is different from '5.1' that was encountered earlier" error. Why is it encount...

Where can I Find some Good Linq to Entities Tutorials?

I am getting started with Linq to entities and do not know where to start. Can you recommend some good tutorials online and some good books I can buy? ...

JOIN/query accross separate entities.

What are the current options for querying and joining two different Entity Data Models? I've seen that it's possible to share a single model schema between multiple mapping and storage schemas, but it seems clunky and not encouraged. The other option I can think of is to query the entities separately and then join the linq objects, but I...

Entity Framework T-Sql "having" Equivalent

How can I write a linq to entities query that includes a having clause? For example: SELECT State.Name, Count(*) FROM State INNER JOIN StateOwner ON State.StateID = StateOwner.StateID GROUP BY State.StateID HAVING Count(*) > 1 ...

How should I write this Linq to Entity query?

I'm new to Linq to Entity stuff, so I don't know if what I'm doing is the best approach. When I do a query like this it compiles, but throws an error that it doesn't recognize the method GetItemSummaries. Looking it up, this seems to be because it doesn't like a custom method inside the query. return (from c in _entity.Category ...

Entity Framework in Partial trust environment

I know that Entity Framework supports Partial trust, I personally blogged about that It was working fine, I tested it and it was fine. Now if you download the samples attached to my post about the subject, it doesn't run under default partial trust anymore!!! When I dug into System.Data.Entity assembly using reflector on the position ...

Do you Guys use Linq on Enterprise Applications?

I have gone to an interview at toyota and was very surprised the interviewer asked me questions about Linq. I can't believe Linq is being used by these big corporations. Do you guys use linq where you work at? ...

dynamic linq contains

Hello all, i search for a dynamic linq-to-sql Contains (StartsWith / EndsWith) method. I’ve tried the following code, but it didn't work. Any ideas? public static IQueryable<T> WhereContains<T, V>(this IQueryable<T> queryable, string propertyName, V propertyValue) { ParameterExpression pe = Expression.Parameter(typeof(T), "p"); ...

Linq to Entities - Eager Loading

I have a complex object and when I use a linq query without the Include syntax, I am still getting all the related entities back in my object graph. Wha can explain this? ...

Initializing strongly typed objects in LINQ to Entities

I have a plain old CLR object which is essentially a wrapper for two entity framework objects, I'm doing this so I can pass this wrapper object to a strongly typed view in the MVC framework. My foo wrapper class is very simple: public class FooWrapper { public FooWrapper(Foo f, Bar b) { this.FooObject = f; this.B...

Eager loading in Entity Framework fails on complex query

The following query fails to load the tables when I execute it: IEnumerable<Bookmark> tempBookmarks = ListBookmarksByUserID(userID); IEnumerable<CandidateWithBookmarks> results = (from c in _internshipEntities.CandidateSet .Include("education") .Incl...

Query Builder vs Linq to Entities

I have been hearing that the built in query builder for the entity framework is much faster to then Linq to Entities. Is this true? If so, can I use the query builder for any type of query? ...