entity-framework

Need help trying to EagerLoad some data in EntityFramework.

Hi folks, I'm trying to do some eager loading on an EF Entity. so, if the entity is called Orders .. then I guess i would do the following... _someContext.Orders.Include("Whatever") .... But the problem is, I have a method like the following ... public IQueryable<Order> Find(Expression<Func<Order, bool>> predicate) { return Curr...

LINQ to Entities many to many relationship

I am new to LINQ and the Entity Framework and am having trouble coming up with a suitable query. I have the following entities. I have included primary keys and some other relevant fields. Contact Int ContactId(PK), String Name, String EMailAddress Project Int ProjectId(PK) ProjectContact Int ProjectId(PK), Int ContactId(PK), Boolean...

how to export ADO.net entity data model to a .mdf file?

Hi, I've created my first ADO.net entity data model. In it there are 2 tables (with no relations, just simple tables). In my Project's App_Data directory there is an (empty) mdf file called "trans.mdf". When I select "generate database from model" in the ADO.NET model, I can select my "trans.mdf" in the dialog. It then builds the dd...

C# ADO.NET Entity

Hi all Here is the question : I have following entities: Every time i update or insert a transaction i would like to autodetect the category depending on ReferenceMappingExpression or DescriptionMapppingExpression in CategoryMappings Entity. I mean i want to match Transaction.Description to CategoryMappings.DescriptionMapping and if i...

Is retrofitting Entity Framework into my app appropriate for my situation?

So, I have an app that uses a SQL Server express db. I have about 80ish tables all with a primary key but no foreign keys. (The reason we have no foreign keys is because of how we do our sql client-to-server replication. It's not true replication but it's a sync system that was in place when we took over the app. We have no guarantee wha...

Entity Framework Views and Linq .Where

I have a very small entity framework setup containing only a few related classes/tables and a view. I need to be able to pull a specific record from this view, namely, I need to be able to grab the record that meets two criteria, it has a specific ProfileID and a specific QuoteID. This line is what's causing the problem: TWProfileUpcha...

Entitiy Framework - DB round trips

I would like to know if exists a way to log all DB trips from Entity Framework. I have google it, but I didn't found ...

Why would you not use WCF Data Services for querying data?

OK, so we are using entity framework and wish to expose data from these entities to consumers. This data is pretty common and although initially only consumed by WPF applications it could be consumed by other technologies such as Silverlight, ASP.NET, Office, etc in the future. Typically you would build WCF services that expose a number...

ADO.NET Entity Framework - Composite primary key CRUD

Hi all i have following entities as you see BudgetPost has a composite primary key which is a foreign keys to entities Category and Budget. My question is what is the best way to make CRUD? Is there any way to mapp the foreign keys? The simple insert should look like this: Budget newBudget = new Budget(); newBudget.Bu...

Entity Framework: ObjectSet and its (generics) variance

I use: EntityFramework + POCO Here is the thing: public interface IBaseType { int Id { get; set; } } public class BaseType : IBaseType { public virtual int Id { get; set; } } public class DerivedType : BaseType { } The problem: public class EntityFetcher<T> where T : BaseType { public object GetById(int id) { ...

Moving from custom n-tier OR/M to EF4

I currently have a custom ORM. I have a business layer, and data layer. My Data layer has all my CRUD operations. In the example below, I pass an Id to the constructor. This gets the record from the DB and fills the object with my person record: E.g. //Access through business layer Dim person as new Business.Person(Id:=1) person.Data...

How should I expose database classes over web services?

Given that directly exposing linq to sql or entity framework classes over web services is a bad idea, how should I expose the data over a web service such as WCF? It seems like I would have to create a parallel set of classes for the web service, and then marshal the data into those, which doesn't seem very elegant. The web services wi...

entity framework + repository + unit or work question

I'm thinking about starting a new project using EF 4 and going through some articles, I found an article about EF with repository pattern and unit of work (http://blogs.msdn.com/b/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx) Looking at that article, it uses the ObjectContext as the...

Having serious problems with Entity Framework & Foreign Keys :(

Hi folks, I've got the following entities on my EDMX :- These two entites were generated by Update Model From Database. Now, notice how my country has the following primary key :- Name & IsoCode this is because each country is UNIQUE in the system by Name and IsoCode. Now, with my States ... it's similar. Primary Key is :- Name ...

Entity framework : Watch changes saved on my objects

Hi, For my project, I have to log all changes made on my objects, through the entity framework. This consists just to register which fields have been edited on which table at which time. Roughly, put changes in a table with this kind of structure: IDEvent, EventDate, TableName, RowID, FieldName, OldValue, NewValue If there is multiple...

Help needed on linq query

Hi, This is my SQL table: i d person datetime status description1 description2 ----------- -------------------- ----------------------- ---------- --------------- --------------- 1 personA 2010-01-01 20:00:00.000 A desc1 desc2 2 personA 2010-01-01 21:00:00.000 B desc3 desc4...

Refresh CollectionViewSource (Entity Framework) bound control

I can't believe I can't find an answer to this... I've created Entity Framework models generated from DB (SQL Server CE) I dragged an Entity from Data Sources to my MainWindow, automagically creating this XAML: <Window.Resources> <CollectionViewSource x:Key="contentItemsViewSource" d:DesignSource="{d:DesignInstance my:ContentItem, Cre...

CLR detected an Invalid Program

Need any help, ideas to figure out this issue. We are working on an application that makes a call to SAP for posting some data using ERPConnect. We encounter the following issues in one of our Entity Framework call in our WCF service. We are using .NET4.0, Win 2008 Server. The following information was included with the event: excep...

Upcasting without retaining reference to derived type

I have a class called Resource, this is inherited by a class called ResourceMeta I need to upcast ResourceMeta to Resource without it still thinking it is a type of ResourceMeta. When I try to save my object using entity framework, it will complain about mappings not existing, rightly so because it will be trying to save ResourceMeta r...

MySql Entity Framework Select

I am having trouble with an MySql query. string strSql = "select SQL_CALC_FOUND_ROWS *, pv.* from products pv WHERE pv.name = 'Teddy Bear';"; strSql += "SET @resultCount = FOUND_ROWS();" MySqlParameter parm = new MySqlParameter("@resultCount",MySqlDbType.Int32) parm.Direction = ParameterDirection.Output; var result = ObjectContext.Ex...