🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / .Net Core Web Api / NotMapped kullanımı bir model de mssql de alan olmamasını sağlar entity bozulmaz bu sayede fazla parametre alabilirsin

1-) .Net Core Web Api  - NotMapped kullanımı bir model de mssql de alan olmamasını sağlar entity bozulmaz bu sayede fazla parametre alabilirsin

 

 

örnek : sorumluUserIdList için her satır için insert eden kayıt yazalım

 

 

using System.ComponentModel.DataAnnotations;

using System.ComponentModel.DataAnnotations.Schema;

 

namespace GorevTakipPk

{

    public class GorevTakip

    {

        [Key]

        public int id { get; set; }

        public string ad { get; set; }

       

        [NotMapped]

        public List<int> sorumluUserIdList { get; set; } = new();

    }

}

 

 

 

 

 

 [HttpPost("addAll")]

 public IActionResult addAll( GorevTakip data)

 {

     using var context = new Context();

 

     foreach (var uid in data.sorumluUserIdList)

     {

         data.id = 0;

         data.sorumluUserId = uid;

         context.Add(data);

         context.SaveChanges();

     }

 

     return Ok();

 }

 

 

 2025 Ağustos 21 Perşembe
 58