I have this class:
public class ContentViewModel
{
public Content Content { get; set; }
public bool UseRowKey {
get {
return Content.PartitionKey.Substring(2, 2) == "05" ||
Content.PartitionKey.Substring(2, 2) == "06";
}
}
public string TempRowKey { get; set; }
}
I’m doing this now:
var vm = new ContentViewModel();
vm.Content = new Content(pk);
vm.Content.PartitionKey = pk;
vm.Content.Created = DateTime.Now;
Is there some way that I could change my ContentViewModel so that I don’t need to do the last three
statements?
Why not pass in a parameter to your constructor?
In general consider OOP and the Law of Demeter: Don’t access nested properties if you don’t have to and tell objects what to do but not how (let the object itself decide on that).