using System;
using System.Collections.Generic;
using System.Linq;
namespace TestApp
{
public class Program
{
public partial class Products
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public bool IsActive { get; set; }
}
public class ProductsViewModel
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public bool IsActive { get; set; }
public static implicit operator ProductsViewModel(Products obj)
{
return new ProductsViewModel()
{
ProductName = obj.ProductName,
IsActive = obj.IsActive,
ProductId = obj.ProductId,
};
}
}
static void Main(string[] args)
{
var products = new List<Products>()
{
new Products(),
new Products()
};
var productsViewModels = products.Where(p => p.IsActive)
.Select(x => { ProductsViewModel model = x; return model; });
}
}
}