Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> [SOLVED] TypedList Joining Same Table Twice?
 

Pages: 1
Bugs & Issues
[SOLVED] TypedList Joining Same Table Twice?
Page:1/1 

  Print all messages in this thread  
Poster Message
DaveR
User



Location:

Joined on:
15-Jun-2004 16:37:10
Posted:
43 posts
# Posted on: 20-Aug-2004 23:09:31.  
I have a table with more than one FK to the same table. I'd like to create a TypedList joining that table twice, once on each key.

As far as I can tell there is no way to do this in LLBLGen, and I need to resort to a TypedView. Is this correct?
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 20-Aug-2004 23:41:32.  
True.

This limitation will be addressed shortly in an update to the runtime libs, however the designer will have this ability within a few months.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
JohnRLewis
User



Location:
Seattle, WA
Joined on:
30-Aug-2004 17:56:52
Posted:
27 posts
# Posted on: 30-Aug-2004 18:03:22.  
I have the same issue.

Asset
- AssetID (PK)
- <other fields>

Relationship
- AssetID1 (PK) (FK1)
- AssetID2 (PK) (FK2)
- <other fields>


I need to be able to retrieve all assets that are related to a particular asset. Whether they are referenced via AssetID1 or AssetID2.

What would that view look like?

  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 30-Aug-2004 18:28:45.  
JohnRLewis wrote:
I have the same issue.

Asset
- AssetID (PK)
- <other fields>

Relationship
- AssetID1 (PK) (FK1)
- AssetID2 (PK) (FK2)
- <other fields>
I need to be able to retrieve all assets that are related to a particular asset. Whether they are referenced via AssetID1 or AssetID2.
What would that view look like?

At the moment your only option is a view. The updates which make this possible are currently in beta and are expected within a few weeks as final. Your question is what the sql looks like for the view?


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
JohnRLewis
User



Location:
Seattle, WA
Joined on:
30-Aug-2004 17:56:52
Posted:
27 posts
# Posted on: 30-Aug-2004 21:12:43.  
How do I do this using the beta? I do not see the ability to add the table twice.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37804 posts
# Posted on: 30-Aug-2004 21:36:37.  
JohnRLewis wrote:
How do I do this using the beta? I do not see the ability to add the table twice.

Yes you can do it in code:
Code:

/// <summary>
/// Tests the group by clause functionality.
/// </summary>
[Test]
public void GroupByTestCustomList()
{
    DataAccessAdapter adapter = new DataAccessAdapter();
    ResultsetFields fields = new ResultsetFields(3);

    fields.DefineField(EmployeeFieldIndex.FirstName, 0, "FirstNameManager", "Manager");
    fields.DefineField(EmployeeFieldIndex.LastName, 1, "LastNameManager", "Manager");
    fields.DefineField(EmployeeFieldIndex.LastName, 2, "AmountEmployees", "Employee", AggregateFunction.Count);
    IRelationPredicateBucket filter = new RelationPredicateBucket();
    filter.Relations.Add(EmployeeEntity.Relations.EmployeeEntityUsingEmployeeId, "Employee", "Manager", RelationWeaknessHint.None);
    filter.PredicateExpression.Add(PredicateFactory.CompareValue(EmployeeFieldIndex.LastName, ComparisonOperator.Equal, "Manager", "Buchanan"));
    IGroupByCollection groupByClause = new GroupByCollection();
    groupByClause.Add(fields[0]);
    groupByClause.Add(fields[1]);

    try
    {
        DataTable tlist = new DataTable();
        adapter.FetchTypedList(fields, tlist, filter, 0, null, true, groupByClause);

        Assert.AreEqual(1, tlist.Rows.Count);
        Assert.AreEqual(3, (int)tlist.Rows[0]["AmountEmployees"]);
    }
    finally
    {
        adapter.Dispose();
    }
}

This joins employees twice.

Selfservicing:
Code:

/// <summary>
/// Tests the group by clause functionality.
/// </summary>
[Test]
public void GroupByTestCustomList()
{
    ResultsetFields fields = new ResultsetFields(3);

    fields.DefineField(EmployeeFieldIndex.FirstName, 0, "FirstNameManager", "Manager");
    fields.DefineField(EmployeeFieldIndex.LastName, 1, "LastNameManager", "Manager");
    fields.DefineField(EmployeeFieldIndex.LastName, 2, "AmountEmployees", "Employee", AggregateFunction.Count);
    IRelationCollection relations = new RelationCollection();
    relations.Add(EmployeeEntity.Relations.EmployeeEntityUsingEmployeeId, "Employee", "Manager", RelationWeaknessHint.None);
    IPredicateExpression filter = new PredicateExpression();
    filter.Add(PredicateFactory.CompareValue(EmployeeFieldIndex.LastName, ComparisonOperator.Equal, "Manager", "Buchanan"));

    IGroupByCollection groupByClause = new GroupByCollection();
    groupByClause.Add(fields[0]);
    groupByClause.Add(fields[1]);

    DataTable tlist = new DataTable();
    TypedListDAO dao = new TypedListDAO();
    dao.GetMultiAsDataTable(fields, tlist, 0, null, filter, relations, true, groupByClause, null, 0, 0);

    Assert.AreEqual(1, tlist.Rows.Count);
    Assert.AreEqual(3, (int)tlist.Rows[0]["AmountEmployees"]);
}


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


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

Version: 2.1.12172008 Final.