Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to make anonymous type linq query custom model binding

$
0
0

Hi. I want bind my cutom model (DenetlenenViewModel) but "Yil" property is List. How to bind model linq query?

My Custom Model

public class DenetlenenViewModel
    {
        public int Id { get; set; }
        public string FirmaAdi { get; set; }
        public List<int> Yil { get; set; }
    }

My  Method

public IEnumerable<DenetlenenViewModel> YillarlaBirlikteGetir()
        {
            var firmalar = (from t in FASDBContext.Teklif
                            join d in FASDBContext.Denetlenen
                            on t.DenetlenenId.Value equals d.Id
                            select new DenetlenenViewModel
                            {
                                Id = d.Id,
                                FirmaAdi = d.FirmaAdi,
                                Yil = List<t.Yil> // Error : 'List<t.Yil>' is a type, which is not valid in the given context 
                            }).ToList();
            return firmalar;
        }


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>