entity-framework

Dynamic tables from a stored procedure using Linq to Entities

Hi, I have a question about Entity Framework and Linq to Entities. My .NET version is 4.0. I'm refactoring the database access layer of an existing application, and I plan to use Linq to Entities (instead of today's DataReaders and SQL strings). The structure of the database cannot be altered. My problem comes from a stored procedure, ...

How can I pass a list of object in a SQL Procedure with SQL Server 2008 ?

How can I pass a list of object in a SQL Procedure with SQL Server 2008 ? I want to avoid this : foreach (var item in itemList) { myContext.ExecuteStoreCommand("EXEC MyAtomicProc ... item ...); } I want to do the foreach in a store procedure. How can I pass a c# list of object and execute this procedure in EF : myContext.Execut...

Can you use Microsoft Entity Framework with Postgres?

Well, there is similar question for Oracle, now, Postgres? ...

Entity Framework Attach Exception After Clone

After trying several options of having a decent mechanism which allows to use ObservableCollections with the option to dynmically having them updated using an Edit window and binding, without having the global collections updated while making changes on the bound controls, so far the best solution seems to be : Clone the entity, detach t...

Generating Entity Framework based on Views: Nullable types

Some of the properties in a class generated by EF are nullable, and some arent. My first instinct was that this should be driven by Nullable property returned by sp_help MyView. But that doesn't seem to be the case. Some of my types that are returned as Nullable by sp_help get generated as Nullable , while others, get generated as ju...

The type parameter 'POCO Class' in ExecuteFunction is incompatible with the type 'EFComplexType' returned by the function

We've got an EF model that's using POCO generation for its types. We added a stored procedure and created a function import for it. We then generated a Complex Type for the result set and let the T4 template generate the business contract (POCO). Everything works great in our development, devint, and QA environments. When we deploy to p...

Querying Entity Data Model from C# code

Hello, I have an application with an Entity Data Model. I do not completely understand the value of an Entity Data Model. Either way, I know that it connects to my database and interacts with it. I have some C# code from which I want to execute a stored procedure. My problem is, I'm not sure how to do this using the "Entity Data Model" ...

Lazy loading a subclass from a POCO in Entity Framework 4.0

I was wondering if anyone has attempted to lazy load a subclass (where is isn't known what the subclass is until the result is returned) using EF and POCOs? This is a bit of a nightmare in NHibernate, but works as long as you don't attempt to cast the returned result to a subclass (because a proxy of the base class is created, it can't ...

Enterprise Library 5 Logging block throws SynchronizationLockException

Inside Global.asax.cs I get: Object synchronization method was called from an unsynchronized block of code protected void Application_Start() { InitContainer(); AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); ControllerBuilder.Current.SetControllerFactory(typeof(UnityControl...

DataSource.Table.Where(stringOfConstraint) does not exist in LinqToSQL for OData support?

I'm looking at this Telerik demo, and am unable to get the "count" statement to work. I believe that the following command is only supported on EntityFramework, and not Linq2SQL. return CurrentDataSource.Products.Where(where).Count(); The parameter "where" in lowercase is actually a string that is passed in the ADO.Net DataServices ...

Can you map the results of a manual SQL query to objects in Entity Framework?

In LINQ, you can write a manual SQL query, take the results from it and have LINQ "map" those into the appropriate properties of your Model classes (or at least, I'm pretty sure I read you can do that). Is it possible to do something like that in Entity Framework? I have an web app that's using EF, and it's CPU usage is ridiculously hi...

Entity Framework Foreign Key Queries

I have two tables in my entity framework, objects, and parameters which have a foreign key pointing to the object to which they belong. I want to populate a tree with all the attributes of a certain object. So in order to find those I want to do this: String parentObject = "ParentObjectName"; var getAttributes = (from o in myDB....

Select all fields from table using Entity Framework

In the code below all of the fields are returned from the tables except for fields that are foreign keys. How do I get the foreign key fields to display? I just want an equivalent to select * from tableName. public ActionResult ShowAllTables() { var model = new CSLA_StagingModel() { depots =...

Entity framework, check duplicates ignoring case

Hi, I want to check for duplicates in Entity Framework using Linq-To-Entities, ignoring cases. What's the best way to do it? As far as I'm aware, context.[Entity].Contains(item, IEqualityComparer) method is not supported. Do I have to do ToList() which reads the entire table into memory just to check it? Thanks, ...

EF4 Context.ApplyCurrentValues does not update current values.

I have a entity that I retrieve as follows and is detached from the context: ctx.Reviews.MergeOption = MergeOption.NoTracking; Review review = (from r in ctx.Reviews.Include("ReviewNotes") where r.ReviewID == reviewID select r).First(); I then make changes to an object in the relationship: if (revie...

How to view generated SQL from Entity Framework?

As the title says, how do I view the SQL generated by Entity Framework from within my code? I'm running into an error where the EF is crashing because a field is generated by the database (a DateTime field), and I thought I set it to know that the store is generating it via StoreGeneratedPattern, but it's still crashing, so I would like ...

Define a seperate ViewModel for EditProfile View or use the User model (DRY vs convenience)

For my Edit Profile page, all the items are from the User entity. Things like email, password, fullname, city, etc. I'm using ASP .NET MVC2 along with Entity Framework 4. I'm wondering if I should create a separate ProfileModel for my EditProfile View or if I should just use the User entity created by EF. My dilemmna is that if I crea...

How to handle database operations using threadpool and entity framework?

Hi! I really need some code examples here... What I am trying to do: GetCollectionFromDatabase foreach item { resetEvents[i] = new ManualResetEvent(false); var makeRequest = new MakeRequest(resetEvents[i]); ThreadPool.QueueUserWorkItem(new WaitCallback(makeRequest.ThreadPoolCallback), i); } ...

See version of Entity Framework

Hello, I have a VS2008 web project with a EF1 datamodel. Now I have converted this to a VS2010 project with .Net 4. My question is about the Entity Framework. How can I see what version of EF it is. Or how can I make sure it is EF 4? ...

How to Support Localization by mapping two entities to one POCO in EF 4

Hi, I've this simple Entities from DB tables But i want my POCO classes to be just two classes: public class Country { public string ID { get; set; } public string Name { get; set; } public string LocalName { get; set; } // this localized public string Region { get; set; } public IEnumerable<City> Cities { get;...