IsMappedOnResultset equivalent on Lpt templates

Posts   
 
    
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 04-Apr-2012 23:23:15   

Is there any equivalent in .lpt to the TDL [If IsMappedOnResultset] token? I have looked into TypedViewDefinition object, but I cannot find anything similar.

Of course I could set a CustomProperty, but it seems a bit weird.

Update: It seems to be defined in the SD.LLBLGen.Pro.DBDriverCore.ProjectElementMapTargetElementType enum, and that could be retrieved by GroupableModelElementMapping.MappedTarget.ElementType, but I don't know how to get to a GroupableModelElementMapping from a TypedViewDefinition

TIA, Jose

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 05-Apr-2012 09:40:16   

Not sure but I think you need the TypedViewMappings which you can cast to GroupableModelElementMapping. So you get all TypedViews mapping information which you can query upon.

Please check this specific post: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=19171&StartAtMessage=0&#107971

raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 05-Apr-2012 16:40:56   

Cool!!! Here is the code:

var databaseMappingData = _executingGenerator.ProjectDefinition.MappingData.MappingDataPerDriverID
                    .FindByKey(_executingGenerator.DriverID).FirstOrDefault();
var tpvsMappedToSP = databaseMappingData.TypedViewMappings
                    .Cast<GroupableModelElementMapping>()
                    .Where(m => m.MappedTarget.ElementType ==
                         ProjectElementMapTargetElementType.StoredProcedureResultset)
                    .Select(m => m.MappedElement.Name);
bool currentTypedViewMappedToSP = tpvsMappedToSP.Contains(currentTypedView.Name);

As always, superb! Thanks.

raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 05-Apr-2012 17:01:25   

Even better:

TypedViewMapping currentMapping = currentProject.GetGroupableModelElementMapping(currentTypedView, _executingGenerator.DriverID) as TypedViewMapping;
bool currentTypedViewMappedToSP = (currentMapping.MappedTarget.ElementType == ProjectElementMapTargetElementType.StoredProcedureResultset);