dstr
dstr

Reputation: 8938

Entity Framework considerations for ASP.NET applications

I've created a business layer with a database model to be used in an ASP.NET application. I've used Linq To SQL Classes in Windows Forms before but using ORMs in per-request web applications is foreign to me. I've a few things I couldn't figure out and I'd appreciate if anyone give me any insight..

My BLL has static methods like GetRecord() or UpdateRecord(). Each one of these methods creates a new ObjectContext instance, destroyed after unit of work. I don't have any HttpContext.Current.Items cache implementation.

I'm using EF .NET 3.5.

  1. I've created a pre-generated view (Model.View.cs) and added it to my solution. Is this all I have to do to use it? Also do I need to publish csdl, msl and ssdl files with my dll?

  2. Is precompiling queries bad for ASP.NET applications? I have like only one or two queries for any ASPX page and very rarely a select query used twice in the same page. Will it slow down the application if precompile my queries? I wonder if a precompile made by Session A would be useful for Session B?

  3. I've created the following method to update a record in ASP.NET page and I wonder if it is a good way to do it:

    ASP.NET gets the record(Entity) using BLL.GetRecord()
    Updates any values
    Sends updated record to BLL.Update()
    BLL.Update() checks if the record exists
    Uses context.ApplyPropertyChanges() to update the record

  4. I've red a few entity framework performance charts and in every one of those charts there are two different statistics for queries: first run and the second run. Since I work with unit-of-work type of design, will my queries never see second runs?

Thanks.

Upvotes: 0

Views: 191

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126587

  1. You need the CSDL, etc., either as files or resources. View pre-generation helps with performances, but doesn't relieve you of the need to include EDMX in some form.
  2. No.
  3. OK as far as it goes. Hard to say more without seeing code.
  4. It depends. This post should help.

Upvotes: 1

Related Questions