smiledragon wrote:
I have read some threads about INNER JOIN but I only the answer for following sql query
select tabs.*
from tabs inner join portals on tabs.portalid = portals.portalid
// select tabs.* FROM tabs INNER JOIN portals ON tabs.PortalID = portals.PortalID where tabid = @tabid
using (DataAccessAdapterBase adapter = DataAccessAdapterFactory.CreateAdapter())
{
IEntityRelation relation = new EntityRelation();
relation.AddEntityFieldPair(EntityFieldFactory.Create(PortalsFieldIndex.PortalId), EntityFieldFactory.Create(TabsFieldIndex.PortalId));
relation.StartEntityIsPkSide = true;
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(PredicateFactory.CompareValue(TabsFieldIndex.TabId, ComparisonOperator.Equal, tabId));
filter.Relations.Add(relation);
EntityCollection entityCollection = new EntityCollection(new TabsEntityFactory());
adapter.FetchEntityCollection(entityCollection, filter);
}
not this
select portals.*, tabs.*
from tabs inner join portals on tabs.portalid = portals.portalid
how could I get all portals' field and tabs' fields using above code?
You either use a typed list or a dynamic list. A typed list is easier to set up and use. You go into the designer, add the relation between portal and tab (if it's not already there) and add both portal and tab to a new typed list. Then simply check the checkbox above all fields and all fields are added to the typed list. Generate code and your list is ready to be used.
You can also create a dynamic list, which fetches fields into a datatable. Please see the typedlist/view documentation in the manual for an example of a dynamic list.
If you want all portal and tab entities in an object graph, you can use a prefetch path.
So, which option do you want to use?