0

I am building an application that will interface with my database backend using EF 6. I have my database built so I will be going the database first approach.

One of the goals will be to utilize the grid control from DevExpress and allow the user to view a Master/Detail style of information for each Facility in my Facility table.

I need the ability to update/insert so I would assume using a view would not be as good as actually supplying the context to the grid's data source.

My question is trying to understand the overhead involved with Entity Framework. If my table contains 20 columns but my Grid only needs 10 of these for viewing/updating/inserting does the application still load ALL of the information into memory? Am I better off using a view for the grid and some form of custom routines for an update?

Idea Man
  • 85
  • 1
  • 6
  • All entity properties corresponding to table fields are loaded. Relations are lazily loaded unless you specify otherwise. As long as one of the 10 unseen columns is not a huge field (e.g. blob), you should not suffer much of a performance penalty. IMHO I would load the full entity unless/until you see a performance problem. – Brian Driscoll Dec 23 '14 at 16:47

1 Answers1

1

It doesn't necessarily load all of the columns. If you're smart about it, you can only have it load those columns that you need using LINQ to Entities.

For example:

var records = db.MyTable.Where(...Some condition...).ToList(); will return all the columns.

But doing it this way

`var records = db.MyTable.Where(...Some condition...).Select(x => new MyModel { ...some fields here... }

will only load those fields that are specified.

I've worked with DevExpress and Entity Framework combined before, and I can tell you that it's relatively painless as long as you understand what you're doing with Entity Framework, and don't just blindly have your grids make queries that can get expensive.

Corey Adler
  • 15,897
  • 18
  • 66
  • 80
  • There's one caveat here in OP's M-d scenario: If OP needs to represent ALL property values in the detail section, then that will require another call to the DB to load all the values for that record. – Brian Driscoll Dec 23 '14 at 16:50
  • Does the second example you provided allow the devexpress grid to update back to the dbContext? For instance I have two tables, Facilities and Employees the master will be 10 columns or so out of the Facilities, the details will need to load employee information. Could you provide an example for that if you have worked with DevEx and EF combined? – Idea Man Dec 23 '14 at 16:57