using System.Collections.Generic;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.CustomTypeProviders;
public static void Main()
var config = new ParsingConfig
CustomTypeProvider = new MyCustomTypeProvider()
var IPName = (XName) "IP";
var OSName = (XName) "OS";
new { OS = "Windows", IPAddress = "127.0.0.1" },
new { OS = "Linux", IPAddress = "127.0.0.2" }
.Select(config, "XElement(@0, new [] { OS, XAttribute(@1, IPAddress) })", OSName, IPName);
foreach (var result in query)
Console.WriteLine(result.ToString());
public class MyCustomTypeProvider : DefaultDynamicLinqCustomTypeProvider
public override HashSet<Type> GetCustomTypes() => new[] { typeof(XElement), typeof(XAttribute) }.ToHashSet();