Page 1 of 1

Explicit construction of entity type in query is not allowed

Posted: Thu 16 Jul 2009 11:38
by crazypit
Hello,

I query 2 DB Entities, Customer & CustomerInfo using DotConnect for Oracle. At the end of my query, i need to create an Entity which is not bound to a DB Table and is made by me, SearchedCustomer. The query is this:

IQueryable result = query.Select(a => new SearchedCustomer
{
Id = (long) a.Customer.Id,
Code = a.Customer.Code,
AccountName = a.CustomerInfo.AccName,
TaxRegNo = a.CustomerInfo.TaxRegno,
IdCardNo = a.CustomerInfo.Identity,
Balance = (decimal) a.Customer.Balance,
BalanceAge=(int)a.Customer.BalAge,Status=a.Customer.Status});

List objCustomers = result.ToList();

Last line raises an error :
{"Explicit construction of entity type 'ExrayEntities.SearchedCustomer' in query is not allowed."}

Funny thing is that using version 5.20.33 of DotConnect for ORacle, everything worked ok. Using the latest version 5.25.37, i get the aforementioned error.

Do i need to change something in the way i design things?

Posted: Thu 16 Jul 2009 12:10
by AndreyR
Please check that the entity you have created in the query (SearchedCustomer) does not have the
Table attribute in the generated code.
We have denied the creation of the Table entities because of possible synchronization issues,
just in the way Microsoft does in LINQ to SQL.

Posted: Thu 16 Jul 2009 13:18
by crazypit
Yes, that worked. Nevertheless, if i try to generate the SearchCustomer entity through Entity Developer, a Table attribute is inserted with an empty name even if i don't specify a Source for it. What is the point of this? Wouldn't be better for the Entity Developer not to generate a Table attribute at all? This way, all the unbounded entities could be properly maintained through it.

Posted: Thu 16 Jul 2009 14:11
by AndreyR
Thank you for the suggestion, we are already working on it.
The entities with empty Source propery will not have the Table attribute.
As a temporary workaround, I recommend you to move the code associated with the SearchCustomer entity
to the DataContext.cs class (it is not affected by model changes).

Posted: Fri 23 Oct 2009 08:42
by AndreyR
The requested functionality is implemented in the upcoming Beta build of Entity Developer.

Posted: Mon 02 Nov 2009 08:23
by AndreyR
The Beta build is available for download.