public void CopyTo(article article) { foreach (var propertyInfo in article.GetType().GetProperties()) { if (!propertyInfo.Name.Contains("Id") && (propertyInfo.PropertyType.IsValueType || propertyInfo.PropertyType.Name == "String")) { propertyInfo.SetValue(article, propertyInfo.GetValue(this)); } } }
public NewArticleModel(article article) { foreach (var propertyInfo in article.GetType().GetProperties()) { if (propertyInfo.PropertyType.IsValueType || propertyInfo.PropertyType.Name == "String") { propertyInfo.SetValue(this, propertyInfo.GetValue(article)); } } SubCategories = article.articlesubcategory.Select(sc => sc.CategoryId).ToList(); }