entity-framework-4

Validating data contracts using business logic (entity based).

All my service methods use a facade to talk to the business logic. This means that in the facade the DataContracts (I'm using WCF) are translated to entities (Entity Framework) and then passed on to the business layer. The problem I'm facing right now is that I want to put certain validation logic in the business logic, but this keeps fr...

Entity Framework Rounding

One of my entity objects (EF4) has a property that is a decimal. The field in the database is Decimal(18,2) If I set the value to 30.4777 it only sends 30.47 over to the db in the insert statement (as confirmed by the tracer). Is there a way to get it to send 30.4777 and then just let the database round it off (which it seems happy t...

If you generate a database using EF, do you also use EF to manage the database?

"Manage" as in, make changes to the tables. If yes, how does this work with multiple developers and multiple copies of the database (for development/production)? ...

LLBLGen Pro with Entity Framework 4?

Hi All, I am doing a small study about what ORM to use for our next project. I have narrowed down to LLBLGen Pro / EF4. My question is: I am more convinced about EF4. Should we use EF4 alone or should we purchase LLBLGen Pro and select EF4 as target framework? Are there any advantages/disadvantages in doing so? Any guidance/pointers...

Entity Framework 4 and wcf example needed.

Hi all Totally new to Entity Framework .I have been asked to build a prototype using EF4. This prototype should call an existing WCF Service Uses existing Tables and Stored Procedures Uses existing entities.(poco) Before I go ahead with my prototype I would like to gain some experience on EF4. I have decided to build a small project ...

Cannot update entity in Entity Framework 4 using POCO

I have 2 tables : Item and Location (one - many ). I select one location and I try to update it The entity goes from {Id=2, Name="name1",City="city1",Items=null} to {Id=2, Name="name1", City="city2",Items=null} and i want to save the updates. The update method from the base class is: public virtual void Update(T entity) ...

Entity Framework 4: How to turn a string into an object for .OrderBy(p => p.fieldname)?

Now this is a trick question because you cannot do this: var a = myDB.Where(p => p.field == "filter").OrderBy("it." + fieldname); You could change the Where to accept a string, which allows you to change the OrderBy to accept a string, but that's not the question. How can you turn a string like "productID, productName" in to an Order...

datetime2 and ProviderManifestToken in Entity Framework

I have an MVC app using Entity Framework and a SQL 2008 DB. I used the EF wizard to generate my data model. I have a SQL table with a standard SQL DateTime column. The EF model is using System.DateTime. But when I try to insert a new record into this table from my application, without specifying a value for this DateTime column, I ge...

TPT mapping Entity Framework CTP4 behaving like TPH

I am writing my code as suggested, public class A { public int id {get;set;} public string Astring {get;set;} } public class B : A { public string Bstring {get;set;} } builder.Entity<A>().MapHierarchy( u=> new { ... }).ToTable("A"); builder.Entity<B>().MapHierarchy( u=> new { ... }).ToTable("B"); ... = I have all the pr...

Entity Framework Code First lazy loading non navigation properties

I'm using the entity framework code first CTP4. Is it possible to lazy load non navigation properties like you can in NH 3. A common example would be having a table containing a binary column. I only want to retrieve this column's data when I explicitly ask for that property in my code e.g. image.ImageData Thanks Ben ...

c# List<string> to Lambda Expression with starter example: Refactor to handle the List

I have this: List<string> fields; fields[0] = "firstFieldName"; fields[1] = "secondFieldName"; ... fields[n] = "nthFieldName"; I want to get this: var selector = p => new {p.firstField, p.secondField, ..., p.nthFieldName} // selector is of type Expression<Func<Entity, object>> GoofBallLogic had this code that was simliar, ending ...

In Entity Framework, what is the parent type of all ObjectQuery fields?

I need to OrderBy( p => new SomeClass {p.firstField, p.secondField} ) where public class SomeClass<T> { T firstField {get;set;} T secondField {get;set;} } What is the most specific Entity Framework 4 type that T can be? What code could I use to set firstField's and secondField's value? (meaning I want firstField to referen...

How to save multiple entry for one entity in the same batch . Entity - Relation(One to Many) concept is use in my example.

Here is a common scenario I Have these Entity User UserId UserName ... UserQuestion UserQID UserID UserQuestion UserAnswer When the user first logon, he need to create 3 customs Answer / question. How can I Create these 3 questions relation and save it to database. I Want these questiona in relation with the specific user. ...

Turn "fieldname .startsWith. 'fieldValue'" into .Where(p => p.fieldname.StartsWith('fieldValue')) predicate?

I attempted to do this below, with mind blanks as it got complicated. I need to build a predicate to pass to my Product Repository from a client string: "fieldname .startsWith. 'fieldvalue'" "fieldname .contains. 'fieldvalue'" "fieldname .equals. 3" "fieldname .greaterThan. 3" "fieldname .lessThan. 3" The field names could be any exi...