Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> Set an alias in entity without defined relation in a query using QuerySpec
 

Pages: 1
Bugs & Issues
Set an alias in entity without defined relation in a query using QuerySpec
Page:1/1 

  Print all messages in this thread  
Poster Message
gilles.marceau
User



Location:

Joined on:
14-Feb-2017 11:35:46
Posted:
17 posts
# Posted on: 24-Jan-2020 11:48:23.  
Hi,

Some of my views are reversed as entity because I want to be able to use them in Linq query.
Because theses "entities" are in fact views, they haven't any foreign keyand so I can't use the
Code:
LeftJoin(XXXEntity.Relations.YYYY)
syntax but must use the following one
Code:
LeftJoin(qf.XXX).On(....)


In one of mys query, I want to use QuerySpec and add the same view (as entity) twice but can't figure how to set an alias in this case.

Code:

var query = qf.GenieCivilView
.From(qf.GenieCivilView        
.LeftJoin(qf.StationView, "ALIAS").On(StationViewFields.Id == GenieCivilViewFields.IdStation)


To summary, I want to set an alias on a entity (corresponding to a view) in a query using QuerySpec. Is there a way to do it or not ?

Thanks in advance


* LLBLGEN : 5.6 (5.6.0) RTM - build 2019/08/20
* Database : Oracle 11g
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 24-Jan-2020 12:43:29.  
When needed, you should use .As() to alias the entity, and .Source() to set the alias on the field.

e.g.
Code:
var q = qf.Create()
.Select(
() => new
{
    ID = OrderFields.OrderId.ToValue<int>(),
    LastName = EmployeeFields.LastName.Source("E").ToValue<string>(),
    ManagerName = EmployeeFields.LastName.As("ManagerName").Source("M").ToValue<string>()
})
.From(qf.Order
        .InnerJoin(qf.Employee.As("E")).On(OrderFields.EmployeeId == EmployeeFields.EmployeeId.Source("E"))
        .LeftJoin(qf.Employee.As("M")).On(EmployeeFields.EmployeeId.Source("M") == EmployeeFields.ReportsTo.Source("E")));

var results = adapter.FetchQuery(q);


  Top
gilles.marceau
User



Location:

Joined on:
14-Feb-2017 11:35:46
Posted:
17 posts
# Posted on: 24-Jan-2020 14:46:45.  
Thanks.

As always, efficient Regular Smiley
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.