1

I have an application that I want to migrate to ASP.NET MVC. There are few stumbling blocks that I am not able to clear.

I am using the following components

  • Linq to Entities
  • MVC with Razor

Now I have three major hurdles.

  1. The sql query is quite complex - I want to use it as it is (without Linq )
  2. How to create a view that will display data from this query's resultset
  3. the query involves joins on tables across multiple databases (though on the same server ) - what is the best approach to make it pure-linq in future.
p.campbell
  • 98,673
  • 67
  • 256
  • 322
Sekhar
  • 5,614
  • 9
  • 38
  • 44

1 Answers1

1

I'm still learning the Entity Framework myself, but hopefully my answer will help you out a little with some advice and starting points.

  1. If you have a complex sql query that you want to leave intact as is, your best bet is to add it as a Stored Procedure in your Database. You could then add/call the Stored Procedure using the Entity Framework. You can set up the model to use a stored procedure.

  2. Using my suggestion in #1, I'd recommend you simply build a custom object to store the data in the structure you need it to be in. In your controller (or however you have your project set up for data/business logic) you can populate the object by using EF to call the Stored Procedure. You could then create your view and strongly type it against that object/model and display it in whatever manner it's needed in.

  3. As for this question, I am not sure. However, I did do a quick search and hopefully this thread may help point you in a direction. EF4 cross database relationships

Community
  • 1
  • 1
Delebrin
  • 1,049
  • 4
  • 11
  • 19