Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a way to "kill" a Model Property?
    primarykey
    data
    text
    <p>My application's front end is a <code>DataGrid</code> whose contents are passed to an Excel-generating method.</p> <p>The catch is that the DataGrid deals with 13 columns: 10 of them are fixed (i.e., passed to Excel) while each of the last 3 is optional.</p> <pre><code>public class GridModel { public string Item { get; set; } public string ItemName { get; set; } public double TotalHeight { get; set; } public double AGLheight { get; set; } public double Embedment { get; set; } public string Shape { get; set; } public double TipDiameter { get; set; } public double BaseDiameter { get; set; } public double Taper { get; set; } public double ShearReaction { get; set; } // The following are optional, in 8 combinations, from all present to all absent public double Camber { get; set; } public double Rake { get; set; } public double Angle { get; set; } } </code></pre> <p>Being a C# newbie, I am considering the different approaches.</p> <p>How would you folks deal with this? The simplest idea that comes to mind is to add 3 flags to the model:</p> <pre><code>bool IsColumn1Present; bool IsColumn2Present; bool IsColumn3Present; </code></pre> <p>Another way would be to add a level to the hierarchy, so each of the 'special' columns contains its own embedded flag:</p> <pre><code>if (Camber.flag) add(Camber.value); </code></pre> <p>That said, I would like to have the ability to somehow <strong>remove</strong> those 3 properties, so any attempt to access them would result in an error or impossibility.</p> <p>If such thing exists, I guess it would be called "Variant Properties".</p> <p>TIA</p> <p>Note: I have solved this already by the manipulation of the <code>Visibility.Visible</code> field at the GUI level. Gurus, however, tell us that this is a bad idea. Best practices dictate that this facility should be part of the Model.</p>
    singulars
    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.
 

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