Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting data from an unknow data model
    primarykey
    data
    text
    <p>Okay, so I want to have a generic method that can read data from an unknown data class given a razor type property pointer.</p> <p>I.E. I want to be able to pass in a string containing a template and a object and then extract the data from the object given the string in the template.</p> <pre><code>String template = "@Model.Basket"; var results = parse(template, data); </code></pre> <p>the parse method should have no knowledge of the specific model being passed to it, so its method signature should be something like:</p> <pre><code>public var parse(String template, object model) </code></pre> <p>where data is something like</p> <pre><code>public class Receipt { public String Firstname { get; set; } public String Surname { get; set; } public DateTime TransactionDateTime { get; set; } public Boolean ReturnCustomer { get; set; } public LineItem[] Basket { get; set; } public class LineItem { public Product product { get; set; } public int Units { get; set; } public class Product { public int ProductId { get; set; } public String ProductName { get; set; } public double Cost { get; set; } } } } </code></pre> <p>In this case parse should return an array of line items, but if my template was equal to "@Model.Firstname" it should simply return a string containing the the name stored in that property.</p> <p>Does anyone have any good ideas.</p> <p>Note that for this given solution, I can not make use of the Razor engine as my templates are not in a format that the razor engine can understand.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload