locked
Many L2S Models RRS feed

  • Question

  • User-751080518 posted

    Hi.

    In my web application I have many Linq2Sql models.

    This application will be part of some other application and will be called with one query string parameter.

    Based on this parameter I will select some model.

    What would be the best way to achieve that?

    Is it right way to set DefaultModel

    DefaultModel.RegisterContext(typeof(Models.GrezniceDataContext), new ContextConfiguration() { ScaffoldAllTables = true });

    How could I set Model from string if I would pass ModelName as query string parameter?

    Which event would be the best for setting this and reading query strings?

    I think that ApplicationStart isn't.

    Thanks in advance.

    Borut

    Thursday, April 21, 2011 2:57 PM

Answers

  • User-330204900 posted

    Your big problem here is the fully scaffolded site only load metadata at the Application Start event, I don't think you will get much milage with it.

    You may however regiter ALL the models into an array and then choose you model based on url? see David Ebbo's article here Using Dynamic Data with multiple databases

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 22, 2011 6:00 PM

All replies

  • User-330204900 posted

    Your big problem here is the fully scaffolded site only load metadata at the Application Start event, I don't think you will get much milage with it.

    You may however regiter ALL the models into an array and then choose you model based on url? see David Ebbo's article here Using Dynamic Data with multiple databases

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 22, 2011 6:00 PM
  • User-751080518 posted

    I have all models in directory Models.

    Is it possible to register all models when application starts in foreach loop (*.dbml files)?

    Tuesday, May 3, 2011 3:37 AM
  • User-330204900 posted

    yes I have seen that done see my Dynamic Data – Registering Multiple Models

    Wednesday, May 4, 2011 4:43 AM