New Posts New Posts RSS Feed: query inherited entities
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

query inherited entities

 Post Reply Post Reply
Author
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Topic: query inherited entities
    Posted: 30-Sep-2010 at 10:48am
Hi sky40627;

The reason is that the line

query.ToList();

performs an immediate execution of the query.

This is true for other clauses such as First(), FirstOrNullEntity(), FirstOrDefault(), etc.
Back to Top
sky40627 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Oct-2009
Posts: 34
Post Options Post Options   Quote sky40627 Quote  Post ReplyReply Direct Link To This Post Posted: 29-Sep-2010 at 4:24am
you can ignore last question, Name was not a database Property
 
 
Back to Top
sky40627 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Oct-2009
Posts: 34
Post Options Post Options   Quote sky40627 Quote  Post ReplyReply Direct Link To This Post Posted: 29-Sep-2010 at 4:13am
I have yet another question
 
The specified type member 'Name' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
 
is the error I get when doing this
 
BindableList<Customer> _bl = new BindableList<Customer>();
BindingSource _bs = new BindingSource();
_bs.DataSource = _bl;

       var qry =_entityManager.Countries
==>            .Where(c => c.Name.Contains(pValue));
 
_bl.ReplaceRange(qry.ToList());
 
 
what is the reason for this ? I cannot use "Name" as an entity property ?
Back to Top
sky40627 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Oct-2009
Posts: 34
Post Options Post Options   Quote sky40627 Quote  Post ReplyReply Direct Link To This Post Posted: 29-Sep-2010 at 1:57am
BindableList<Employee> _bl = new BindableList<Employee>();
            BindingSource _bs = new BindingSource();
            _bs.DataSource = _bl;
            IEntityQuery<Employee> qry = (IEntityQuery<Employee>)_entityManager.BasePersons
                .Include(Employee.PathFor(b => b.Address))
                .Include(Employee.PathFor(b => b.Address.Country))
                .Where(b => b.Name.Contains(pValue))
                                ;
            _bl.ReplaceRange(qry.ToList().OfType<Employee>()
);
 
I changed to this and it works fine, why ?
 
Can somebody explain this to me ?
Back to Top
sky40627 View Drop Down
Newbie
Newbie
Avatar

Joined: 06-Oct-2009
Posts: 34
Post Options Post Options   Quote sky40627 Quote  Post ReplyReply Direct Link To This Post Posted: 28-Sep-2010 at 7:41am
when performing this query
 
 BindableList<Employee> _bl = new BindableList<Employee>();
            BindingSource _bs = new BindingSource();
            _bs.DataSource = _bl;
            IEntityQuery<Employee> qry = (IEntityQuery<Employee>)_entityManager.BasePersons
                .Include(Employee.PathFor(b => b.Address))
                .Include(Employee.PathFor(b => b.Address.Country))
                .Where(b => b.Name.Contains(pValue))
                .OfType<Employee>()
                ;
            _bl.ReplaceRange(qry);
 
where Employees are inherited from BasePersons
 
the sql query does not perform the include (there is no join in the sql statement) so the application ends up fetching all Addresses one by one
 
when doing this query for all basepersons then it is ok
 
What is the problem here ?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down