Overview
All LINQ Examples are executed using the same ScriptContext instance below:
LinqContext = new ScriptContext {
ScriptLanguages = { ScriptLisp.Language },
Args = {
[ScriptConstants.DefaultDateFormat] = "yyyy/MM/dd",
["products"] = TemplateQueryData.Products,
["products-list"] = Lisp.ToCons(TemplateQueryData.Products),
["customers"] = TemplateQueryData.Customers,
["customers-list"] = Lisp.ToCons(TemplateQueryData.Customers),
["comparer"] = new CaseInsensitiveComparer(),
["anagramComparer"] = new AnagramEqualityComparer(),
},
// Enable access to .NET Types to Lisp
ScriptTypes = {
typeof(DateTime),
typeof(CaseInsensitiveComparer),
typeof(AnagramEqualityComparer),
},
};
Which makes available the products and customer data sources to each template, all other data sources are created within the template that uses them.
The comparer and anagramComparer are examples of custom .NET objects the templates can't create themselves so they need to defined externally so they're available to the LINQ examples that need them.
The Args[DefaultDateFormat] changes the default format the dateFormat filter uses if none is provided.
View the LINQ Examples in all of #Script Languages: