using System.Collections.Generic;
public static void Main()
var emailTemplate = GetEmailTemplate();
var customer = GetCustomerData();
var emailText = Eval.Execute<string>($"return $$'''{emailTemplate}'''", customer);
Console.Write(emailText);
public static string GetEmailTemplate()
Thank you for your recent order with us! We are currently processing the following items:
<tr><td>Product Name</td><td>Quantity</td></tr>
var sb = new StringBuilder();
foreach(var item in Items) {
sb.AppendLine($$""""""<tr><td>{{item.Name}}</td><td>{{item.Quantity}}</td></tr>"""""");
We will notify you once your order is shipped. You can track the status of your order through your account on our website.
Thank you for choosing us, and we look forward to serving you again!
The Customer Service Team
public static Customer GetCustomerData()
var customer = new Customer() { Title = "Mr.", Name = "Jonathan", Items = new List<OrderItem>() };
customer.Items.Add(new OrderItem() { Name = "C# Eval Expression", Quantity = 1 });
customer.Items.Add(new OrderItem() { Name = "Dapper Plus", Quantity = 4 });
customer.Items.Add(new OrderItem() { Name = "Entity Framework Extensions", Quantity = 9 });
public string Title { get; set; }
public string Name { get; set; }
public List<OrderItem> Items { get; set; }
public string Name { get; set; }
public int Quantity { get; set; }