Sunday, January 6, 2019

Reflection to Get Property value

 var propertyName = DateTime.Now.AddDays(-1).ToString("dddd"); // Always 1 day behind             
                if (filterTimCard.Count > 0)
                {
                    var missingTimeCard =
                        filterTimCard.Sum(
                            x => Convert.ToDecimal(x.GetType().GetProperty(propertyName).GetValue(x, null)));
                    isMissingTimeCard = (missingTimeCard == 0);
                }

No comments:

Post a Comment