How I can using Repository Pattern in C# to get data from two tables without relation between them in DB For example I have table for students and table for details look
public class Student{
public int Id{get;set;}
public string Name{get;set;}
public int GenderId{get;set;}
}
public class DetailsLookup{
public int Id{get;set;}
public string Name{get;set;}
}
I set data for GenderId from (DetailsLookup.Id) but I doesn't create relation between them in DB .
I'm using Repository Pattern in my code and using Unit of work I have idea for code by return StudentViewModel
public class StudentViewModel{
public int Id{get;set;}
public string Name{get;set;}
public int GenderId{get;set;}
public int GenderName{get;set;}
}
and write code in Repository class to get data and return ViewModel
but I read in https://programmingwithmosh.com/net/common-mistakes-with-the-repository-pattern/ We can't return view models/DTOs in Repositories
Help me how I can do it
Aucun commentaire:
Enregistrer un commentaire