0
ITemplateContext ctx = new TemplateContext(); 
List<Orders> ProductList = new List<Orders> { 
new Orders {OrderId = 1,ProductName="Some name",Quantity =30},
new Orders {OrderId = 1,ProductName="Some name1",Quantity =30},
new Orders {OrderId = 1,ProductName="Some name2",Quantity =30} }; 

ctx.DefineLocalVariable("context", new LiquidCollection(ProductList));

Define Liquid Collection with List throws error. Is it possible to define T type generic collection as ITemplateContext-> LocalVariable

DomCR
  • 533
  • 4
  • 19

1 Answers1

0
   ITemplateContext ctx = new TemplateContext();
         List<Orders> ProductList = new List<Orders>
   {
        new Orders {OrderId = 1,ProductName="Some name",Quantity =30},
       new Orders {OrderId = 1,ProductName="Some name1",Quantity =30},
       new Orders {OrderId = 1,ProductName="Some name2",Quantity =30}
    };

        ctx.DefineLocalVariable("context", ProductList.ToLiquid());

Using using Liquid.NET.Utils;