entity-framework

Using ADO.net Entity Framework 4 with Enumerations? How do I do it ?

Question 1: I am playing around with EF4 and I have a model class like : public class Candidate { public int Id {get;set;} public string FullName {get;set;} public Gender Sex {get;set;} public EducationLevel HighestDegreeType {get;set;} } Here Gender and EducationLevel are Enums like: public enum Gender {Male,Female,Undisclosed} pub...

Need help converting a TSQL query to EF using Linq

Here's the query: select FC.Title, COUNT(FSC.ID) as FCCount, COUNT(FP.NoOfSub), MAX(FP.LastPost) from ForumCategories FC left join ForumSubCategories FSC on FSC.CategoryID_FK = FC.ID left join (select SubCategoryID_FK, Count(ID) NoOfSub, MAX(DatePosted) LastPost from ForumPosts group by SubCategoryID_FK) FP on FP.SubCat...

ObjectContext never derives from an interface?? How do you apply DI/IoC in case of multiple types of ObjectContext?

If you have a system that has multiple types of object contexts. For Eg: BillingObjectContext, HumanResourceObjectContext etc. All derive from ObjectContext but ObjectContext Class does not implement any specific interface like IObjectContext. How would you apply DI/IoC in case of multiple types of ObjectContext say using Ninject? ...

"IN" Operator in Linq

I am trying to convert an old raw Sql query in Linq with Entity Framework here. It was using the IN operator with a collection of items. The query was something like that: SELECT Members.Name FROM Members WHERE Members.ID IN ( SELECT DISTINCT ManufacturerID FROM Products WHERE Active = 1) ORDER BY Members.Name ASC Since the return o...

Entity Framework - Missing column(s)?

http://screencast.com/t/ODkwZDQx I have a simple 3 table model built from my DB. Company has 0 or more ProductsSold. Company has 0 or 1 AutoNegotiationDetails. As you see from the diagram, this is what is modeled. However, in the ProductsSold Mapping Details you can see that the CompanyId Value/Property is missing. Nor can I add i...

C# - Entity Framework - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll Make sure you do not have an infinite loop or infinite recursion. The below code is called on a success of this method: internal static List<RivWorks.Model.Negotiation.ProductsSold> GetProductsSoldByCompany(Guid CompanyID) { var ret = from...

Correct interface use with Entity Framework / Linq-to-SQL

I'm about to show my inexperience here, but hey - like any developer I want to learn. Given the following interface: public interface IRepository { entityDB Database { get; set; } IQueryable<T> All<T>() where T:class, new(); T Single<T>(Expression<Func<T, bool>> expression) where T : class, new(); IList<T> Find<T>(Expr...

How to map int into enum with EF

Hi, Is there anyway to map int field into enum in EFv1? Thanks! I want my entity to have enum field rather than int field. ...

Entity Framework multi-language website with multi-database

As the question is a bit self explanatory, I want to achieve the goal of a multi-language website. I am using an Entity Data Model with MS SQL 2005. I came up with an idea of making a seperate database for each language with exactly the same model and relations. So I can use the Entities constructor that takes a connectionString and swit...

Entity Framework + stored procedure with paging

I am using Entity Framework now and using a stored procedure to populate my entity. Where there is no problem with populating my entity, but when i trying to bind the result to a gridview control with "Enable Paging" set to true, it gives an error saying "The data source does not support server-side data paging." I am using stored proc...

How to change the way filters and foreign-key columns are rendered in DynamicData site?

Ok, my title doesn't help. But read the post and you'll understand. What i want to do: Imagine I have a Flyer table with 2 columns in my SQl Server: FlyerID (int)(PK) FlyerDate (smalldatetime) FlyerID is a foreign key on other tables, for example Store table. Store has 3 columns: StoreID (int)(PK) Name (nvarchar) FlyerID (int)(FK...

Can I get a custom sorted EntityCollection by default in EntityFramework ?

Hi, I would like to call a method in the ObjectContext which returns EntityCollection and have it sorted the way I want by default. For example, Imagine I have the following Category table/class: CategoryID (PK) Name ParentID (FK_Category) foreign key pointing to CategoryID itself. (This table is the base for a tree structure of Cate...

How is the performance of entity framework 4 vs entity framework 3.5?

I have one query on my page that takes at least a half second to execute using EF 3.5. When I used a stored procedure the speed was noticably faster. It is a very complex query. Will there be any performance improvements in the upcoming EF 4.0? And does EF 4.0 really beat out 3.5 performance wise? ...

Entity Framework Best Practices: What layer should call SaveChanges()?

For a clean data model, I'm going back and forth on this... Using an approval workflow as an example, let's say in my web application I have a page that lets a user flag a MyEntityObject for approval. MyEntityObject has a few properties that control its approval workflow, so I have a common utility method out there called FlagForApprova...

Saving data for related Tables with foreign key - Entity Framework

I am having trouble saving my entities to the database using EntityFramework. I have to tables, Player and Address. The Player table has a reference to the Address table by means of an AddressId foreign key relationship. So Player.AddressId points to Address.AddressId. Now when calling the following code, I get an error that says: "A de...

Linq with EF dynamic search

I am using EF 3.5 with MVC. I want to made a search page, has some fields for criteria like date, int etc. What is the way in linq to entities to filter the result dynamically. If there are one parameter we can use .where(a=>a.id==1) but many combination with optional param how can i load results and then pass to model. ...

Question on Entity Framework and full-text search

Both Entity Framework and NHibernate are O-R mapping framework. Hibernate can use Lucene as full-text solution. Is there any solution combine Entity framework and Lucene for searching? Where to find out the example/resource for this solution? ...

Domain Driven Design, .NET and the Entity Framework

I'm new to domain driven design but want to learn it and use it for a new application. I will be using Entity Framework for data access. The basic layout so far is: ASP.NET MVC and other clients (mobile devices etc.) | Webservices | Domain Model (Services, Repositories, Aggregates, Entities and Value Objects) | Data Ac...

Installing Entity Framework

Hi there, I'm currently using Entity Framework at my job, but I've recently try to get it on my personal computer but I still didn't find a way to get it. Sure, I've searched on google but not really find any exe and not any thread that explain that. Thanks to help me out! ** EDIT ** I've now access to System.Data.Entity. But I've no...

How to map EntitySql function to a differently named function in the store?

The question is: Given a database backend that understands LeftStr and RightStr: where, in a custom ADO.NET provider implementation, would I establish a mapping to the immutable EDM canonical functions Left and Right? So I am working with the SQLite ADO.NET provider and it works, more or less, until you bump up against some string fun...