Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Llblgen and FOR XML PATH
 

Pages: 1 2
LLBLGen Pro Runtime Framework
Llblgen and FOR XML PATH
Page:2/2 

  Print all messages in this thread  
Poster Message
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38097 posts
# Posted on: 31-Jan-2019 09:15:29.  
To make it work in linq you need a custom extension method which is handled as a function mapping, as the linq provider itself doesn't know how to convert a custom method to a custom predicate nor are there extension points to add that. So to make this work, you effectively have to have a mapping for a .net method which converts to a FOR XML fragment. This is equivalent to the free text search fragment mapping as described in the docs: https://www.llblgen.com/Documentation/5.5/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Linq/gencode_linq_functionmappings.htm#full-text-search
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
TomDog
User



Location:
Wellington, New Zealand
Joined on:
25-Oct-2005 22:21:17
Posted:
570 posts
# Posted on: 31-Jan-2019 12:36:10.  
Yes I already have some function mappings but I didn't think they could take a query as an argument.
I tried this
Code:
new FunctionMapping(typeof(GeneralHelper), "JoinAsString", 1, "{0} for xml path('')")
but I got this error:

The parameter at position 0 is of an unsupported type: Query

Code:
public const string StringJoinSeperator = ", ";

public static string JoinAsString<T>(this IEnumerable<T> input)
{
            return JoinAsString(input, StringJoinSeperator);
}

public static string JoinAsString<T>(this IEnumerable<T> input, string separator)
{
            return input == null ? string.Empty : StringHelper.Join(separator, input.Select(i => Convert.ToString(i)));
}

    /// <summary>
    /// Joins an array of non empty strings together as one string with a separator between each non empty original string.
    /// </summary>
    /// <param name="separator">The separator.</param>
    /// <param name="values">The values.</param>
    /// <returns></returns>
public static string Join(string separator, IEnumerable<string> values)
{
     return string.Join(separator, values.Where(s => !string.IsNullOrEmpty(s)));
}


Jeremy Thomas
VS 2017 C#, LLBLGen v5.4, Winforms, WPF and ASP.NET MVCLLBL & LinqPad
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38097 posts
# Posted on: 31-Jan-2019 16:36:50.  
That's correct, it's a crude way to get some fragments working, but what you want is that the query you specify is first evaluated, and then passed as an argument. It doesn't get that far, simply because function mappings are evaluated before query evaluation. So you can't pass a query as an argument to a function mapping (cyclic dependency).

So I'm afraid it's not going to work what you want. I should have realized that when I replied, I didn't look closely at your example query. Embarrassed
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1 2  


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

Version: 2.1.12172008 Final.