entity-framework

Entity Framework Mapping Question

Trying to map the following schema using the Entity Framework. A Customer can have many associated Stores. A Store can have many associated Customer Each Store can have 0 or 1 and only 1 TopCustomer (the criteria to be a TopCustomer is determined in the business logic) this results with the following mapping in VS. Her...

Is there a way to generically return all of the records from a table with the Entity Framework

Basically I'd be looking to implement a method like this. IQueryAble GetQuery<T>(Entities db) or extension method Entities.GetQuery<T>() This way you could do things like this public IQueryable<T> GetAll() { return yourEntityClasses.GetQuery<T>(); } which would return a SELECT * FROM query expression and obviously from there you c...

what is the difference between ObjectQuery and "var" ?

Look please below what is the difference between two type of codes. is there any performance difference or what else? First Codes ObjectQuery departmans = staffContext.Departman; GridView1.DataSource = departmans; GridView1.DataBind(); Second Codes var departmans = staffContext.Depa...

How to use a stored procedure in ADO.NET Entity Framework

I have 3 tables; I write a stored procedure in ADO.NET Entity Framework. ALTER PROCEDURE [dbo].[sp_GetDepartmanData] (@departman nvarchar(50)) BEGIN SELECT d.ID, d.Name as DepartmanName, sb.Salary, sb.email, sp.Name, sp.SurName, sp.Phone, sp.Married, sp.Address FROM Departman d INNER JOIN StaffsBusin...

How to get store type of an entity set

Hello, I'm trying to filter entities based on their store types (either table or view). I have 2 entities in my test project, one's source is a table and the other's source is a view. <EntitySet Name="Test" EntityType="TestModel.Store.Test" store:Type="Tables" Schema="dbo" /> <EntitySet Name="TestView" EntityType="TestModel.Store.Test...

Sorting gridview using ado.net entity framework

i used below code to fill my gridview but i need sorting gridview . How can i do that in Ado.net enttiy framework? (Sorting gridview if filling gridview with ado.net entity ) void LoadStaffPersonel() { int selectedDepartman = Convert.ToInt32(Request.QueryString["SelectedDepartmanID"]); string name = "...

Comparison between subsonic and ADO.NET Entity Framework which one is faster

I am very confused with the use subsonic or ado.net entity framework Which one I should pefer? I creating a web site using asp.net mvc and all i need is greater performance and I also want to save time using ORM. So Which orm i should use? ...

ADO.NET Entity Framework does not allow gridview clicking sort columns?

I am using the ADO.NET Entity Framework data model. I send data from SQL to a GridView via ADO.NET Entity Framework. But how can i sort gridview'columns click if i use EF ...

Entlib 4.1 in Partial Trust on Azure?

Hi Guys, I am using (or want to use) Entlib 4.1 for Logging in a small app I am building for the Azure Platform - the problem is that I keep getting security exceptions related to Partial Trust? Does anyone know how to correctly set partial trust for azure ? Or has done so ? Thanks ...

Should I use Entities when data access is actually required?

Should I use Entities that are created by the Entity Framework in my code when I don't actually have any data based requirements. The example I am dealing with this is as follows; Users logs in. I look for their user account using Linq to Entity. I store the whole entity object in session. On the next page I load, from session, the auth...

EF in real life, I want to believe (Does anyone have good pointers to non-trivial EF 1.0(3.5) or 4.0 examples?)...

I have recently found myself becoming more negative about EF and cannot help wondering if the real problem is my own knowledge on the subject. I have seen many simple/artificial examples of using EF, especially in conjunction with MVC, but I have not yet found any real-life examples of using EF and taking advantage of all the functionali...

Should I create a ADO.NET Entity Data Model for each table, or one for my entire database?

Hi, Are you supposed to use one ADO.NET Entity Data Model for each table? Or one for your entire database where relationships are also routed, etc... ...

Derived Type with DateTime Condition

I have a Show table, and I would like to have a derived type called ActiveShow which only returns shows in the future Show.ShowDateTime > DateTime.Now Is there a way that I can achieve this using the designer or some other way so that creating an instance of ActiveShow will always adhere to the date condition? ...

Entity Framework references not loading automatically

In the ADO.Net Entity Framework, I have an object which has 4 references to other objects. For some reason, when I query those references, two of them load automatically (as expected), and two of them always return null. Bizarrely enough, when I manually ask the references to load, they load just dandy. As an example: if (account.Hold...

Entity Framework datetime data types mappings

Hi all, I have realized that a smalldatetime sql server data type has been mapped to a datetime in my entity project. Fine with me. When the entity is saving changes it actually uses a datetime2 data type (which currently our production database doesn't support). Now, that's a problem. Looking at the entity designer code i see the prop...

Do you create multiple .dbml/.edmx file for large database when using LINQ2SQL or Entity Framework?

When creating .dbml/.edmx for a database which has a lot of tables, do you use multiple .dbml /.edmx file or just a single giant file? Any pro/cons for splitting the model into multiple file? Thanks, J.W. ...

How do I use Navigational Properties as Primary Keys in Entity Framework (.Net 4.0)?

I'm trying out the Model First approach introduced in Entity Framework with VS2010/.Net 4.0, and now I don't really know how to do this. I start out with the following Entities: Contact Event ******* ***** Id (Int32, not null, pk) Id (Int32, not null, pk) Name (Name, not null)...

Like Operator in Entity Framework?

We're trying to implement the "LIKE" operator in Entity Framework for our entities with string fields, but it doesn't appear to be supported. Has anyone else tried to do something like this? This blog post summarizes the issue we're having. We could use contains, but that only matches the most trivial case for LIKE. Combining contain...

How are foreign keys and Guids dealt with in LINQ to Entities?

Hi, Just using this as an example... Here are the columns in my UserProfile table: ProfileID (Primary key) UserID (Foreign key) Address PhoneNumber now, when I want to add a new user to the database using LINQ to Entities, here is what I'm doing: UserProfile profileToAdd; profileToAdd.ProfileID = 0; profileToAdd.Address =...

What's the equivalence of an SQL WHERE in Lambda expressions?

Hi, Here's what I have: decimal sum = _myDB.Products.Sum(p => p.Price).GetValueOrDefault(); I also have two dates: DateTime start, DateTime end I want to retrieve the sum of all of the product prices between start and end, but I can't figure out how to incorporate the variables into the lambda equation. How do you incorporate variab...