Speed issues after upgrade

3 posts, 0 answers
  1. Jonah
    Jonah avatar
    23 posts
    Member since:
    Oct 2012

    Posted 20 Aug 2015 Link to this post

    I upgraded my Rlinq to a fluent model. Since I have, I am noticing a pretty sharp performance decline.

    This is the link I used to upgrade my project http://www.telerik.com/blogs/benefits-of-code-only-mapping-and-how-to-get-them

    Has anyone else had any issues? Or are there any known issues?

  2. Jonah
    Jonah avatar
    23 posts
    Member since:
    Oct 2012

    Posted 20 Aug 2015 in reply to Jonah Link to this post

    So I thought I would post here just in case anyone else ran into this issue. The slowdown comes from the context calling the PrepareMapping method each time the context is called. If you update your context that was auto created for you which looks like

    private static string connectionStringName = @"FCMWebConnection";
    private static BackendConfiguration backend = GetBackendConfiguration();
    private static MetadataSource metadataSource = new WebServerFluentMetadataSource();
    public WebServer()
    :base(connectionStringName, backend, metadataSource)
    { }

    public WebServer(string connection)
    :base(connection, backend, metadataSource)
    { }

    public WebServer(BackendConfiguration backendConfiguration)
    :base(connectionStringName, backendConfiguration, metadataSource)
    { }

    public WebServer(string connection, MetadataSource metadataSource)
    :base(connection, backend, metadataSource)
    { }

    public WebServer(string connection, BackendConfiguration backendConfiguration, MetadataSource metadataSource)
    :base(connection, backendConfiguration, metadataSource)
    { }

     

    And change it to

    private static string connectionStringName = @"FCMWebConnection";
    static MetadataContainer metadataContainer = new WebServerFluentMetadataSource().GetModel();
    static BackendConfiguration backendConfiguration = new BackendConfiguration()
    {
    Backend = "mssql"
    };
    public WebServer()
    : base(connectionStringName, backendConfiguration, metadataContainer)
    {
    }

  3. DevCraft banner
  4. Kaloyan Nikolov
    Admin
    Kaloyan Nikolov avatar
    118 posts

    Posted 21 Aug 2015 Link to this post

    Hello Jonah,

    I can confirm that your observations are correct. The reason why the default implementation is creating the model each time is that fluent model is dynamic by its nature and in your code could create different mapping based on some conditions. That's why it is up to you to decide how to optimize it. 

    Regards,
    Kaloyan Nikolov
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Back to Top