not implemented on server ('ToCustomer(empl)')

4 posts, 1 answers
  1. Mario
    Mario avatar
    3 posts
    Member since:
    Oct 2008

    Posted 31 Jan 2011 Link to this post

    Hi I'm just playing with SP and external content types. I've written a model in vs 2010 and implemented the GetList, GetItems and update. I'm aggregating different objects (done with the orm wizz) into one single customer (of which i render in a list in SP).

    However the following row gives me an error ' not implemented on server ('ToCustomer(empl)')':
    using (var ctx = new AdventureWorksEntityDiagrams(@"data source=MTO\SOLO;initial catalog=AdventureWorks;integrated security=True"))
    {
        return (from empl in ctx.Employees select ToCustomer(empl)).ToArray(); <- not implemented on server ('ToCustomer(empl)')...
    }
    however this works:
                    var list = new List<Customer>();

                    // ReSharper disable LoopCanBeConvertedToQuery
                    foreach (var employee in ctx.Employees)
                    {
                        list.Add(ToCustomer(employee));
                    }
                    // ReSharper restore LoopCanBeConvertedToQuery

                    return list;

    The ToCustomer is a private static method within the class (never tried to make it public)... it that the issiue?

    Another question (I'm a newbie on this) - the app.config is bypassed by the connection string (explicitly in the c'tor) since i do not want to update the sites web.config (shall I add a web.config somewhere in the wsp deployment with the connection string?). Or how should this be done?

    Cheers,
     Mario
  2. Answer
    Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 02 Feb 2011 Link to this post

    Hi Mario,

    you have hit a limitation that we currently have: In order to leverage the relational server we're trying to push as much as possible to it, and therefore we attempt to do that with your ToCustomer method, which is purely client side.
    What you can do is to use an expression of form

     return (from empl in ctx.Employees select empl).ToList().Select(x => ToCustomer(x)).ToArray();

    The .ToList() will finish and trigger the server side query, and then the resulting list is further been used as input to the Select extension method that can then call your ToCustomer in memory. This has nothing to do with public/private.

    As for your second question: The string that is passed as the argument to the context is tried as the name of a connection string in the connection string settings element in your app.config/web.config. If there is no matching entry, it is tried directly as a connection string. If you do not want to change the web.config, you can hardcode it in your app, but this is usually not something I would do. I would prefer the connection string in the web.config as this gives you more flexibility in the deployment.

    Kind regards,
    Thomas
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
  4. Mario
    Mario avatar
    3 posts
    Member since:
    Oct 2008

    Posted 07 Feb 2011 Link to this post

    Thanks!

    For the second question, yes sure - that's what I want too. Though manually editing the web.config seems like a no good solution... Aren't there any "managed" db connections in sp that have a gui or other in order to have the administrator to "give a final touch" on the db connection that one can use (or other)? Just for curiosity :)

    Cheers,
     Mario
  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 08 Feb 2011 Link to this post

    Hi Mario,

    no, there is currently no way but to change the web.config as text. I think a real administrator should not have a problem with it. If you want to make your app more mouse-friendly, you could always add such a dialog by yourself.

    Regards,
    Thomas
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Back to Top