This is a migrated thread and some comments may be shown as answers.

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

3 Answers 50 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mario
Top achievements
Rank 1
Mario asked on 31 Jan 2011, 03:14 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Thomas
Telerik team
answered on 02 Feb 2011, 05:16 PM
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.
0
Mario
Top achievements
Rank 1
answered on 07 Feb 2011, 09:21 AM
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
0
Thomas
Telerik team
answered on 08 Feb 2011, 10:13 AM
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.
Tags
LINQ (LINQ specific questions)
Asked by
Mario
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Mario
Top achievements
Rank 1
Share this question
or