Joining to Table-Valued Functions in Version 4?

Posts   
 
    
Posts: 22
Joined: 10-Aug-2012
# Posted on: 26-Apr-2013 16:43:07   

Hi, is it possible to join to table-valued functions in version 4?

I.e.:


SELECT * FROM Customer C
INNER JOIN TVF_SomeFunction ('A,B,C') TVF ON TVF.SomeItem = C.CustomerId

If so, how can it be done?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 26-Apr-2013 16:57:36   

What have you tried yourself? You mapped an entity onto a TVF and have used it in a linq or queryspec query and now want to join something to it?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 22
Joined: 10-Aug-2012
# Posted on: 26-Apr-2013 17:00:28   

Otis wrote:

What have you tried yourself? You mapped an entity onto a TVF and have used it in a linq or queryspec query and now want to join something to it?

I haven't tried anything myself further than adding it in the designer. I can call the function from my generated code, but I can't see how I'd go about adding a relation to it.

Is the manual updated yet for version 4? Because I can't find much about the TVF's usage anywhere, hence why I've not been able to get very far myself.

I'm using adapter by the way.

Posts: 22
Joined: 10-Aug-2012
# Posted on: 26-Apr-2013 17:25:51   

OK, I think I found the right bit in the documentation and it works sort of how I was expecting via a Dynamic relation. However, I don't seem to have the TvfCallFactory? What DLL am I missing?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 26-Apr-2013 17:29:02   

Yes, v4's manual is updated to v4 wink It didn't receive a separate chapter, because TVFs are mentioned at the specific places where they're used. So e.g. for queryspec: http://www.llblgen.com/documentation/4.0/LLBLGen%20Pro%20RTF/hh_goto.htm#Using%20the%20generated%20code/QuerySpec/gencode_queryspec_generalusage.htm#tvf you'll see that the method returns an EntityQuery<TEntity> and you can use that everywhere you can use queryFactory.<EntityName>. Key factor you have to remember is to use the alias specified in the On clauses with joins.

In linq, it works a little simpler, as you don't have to specify an alias. LinqMetaData.TVFName(), returns an IQueryable<_EntityName_>, as described in the general usage section of the linq documentation.

Frans Bouma | Lead developer LLBLGen Pro