vendredi 11 septembre 2015

Complex Join with AutoMapper and EF 6

I have a complex database Model with joins. I don't want to use store procedure so I want to use AutoMapper to flatten it so I can query it. I can't seem to figure out how to flatten it using AutoMapper and structuremap. Below are my classes generated from the Entity Framework using code first from existing database. I am using an Interface and Implementing a class to query the objects. I need to get users who has permissions to a contract.

[Table("Contract")] public class Contract { public Contract() { CDRLs = new HashSet(); ContractDocuments = new HashSet(); WDTOes = new HashSet(); }

[Table("PMO")]
public class PMO
{         
    public PMO()
    {
        Contracts = new HashSet<Contract>();
        Products = new HashSet<Product>();
        USERS = new HashSet<USER>();
    }

     [Table("USERS")]
public class USER
{

    public USER()
    {
        Organizations = new HashSet<Organization>();
        Organizations1 = new HashSet<Organization>();
        Products = new HashSet<Product>();
        Products1 = new HashSet<Product>();
        Programs = new HashSet<Program>();
        Programs1 = new HashSet<Program>();
        PMOes = new HashSet<PMO>();
        ROLES = new HashSet<ROLE>();
    }


    [Table("ROLES")]
public class ROLE
{

    public ROLE()
    {
        PERMISSIONS = new HashSet<PERMISSION>();
        USERS = new HashSet<USER>();
        LastModified = DateTime.Now;
        InsertDate = DateTime.Now;
    }

[Table("PERMISSIONS")] public class PERMISSION {

    public PERMISSION()
    {
        ROLES = new HashSet<ROLE>();
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire