Click here to Skip to main content
15,905,233 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionDetect when iOS or Android connected to PC Pin
Becky Alpha5-Jul-14 13:41
Becky Alpha5-Jul-14 13:41 
AnswerRe: Detect when iOS or Android connected to PC Pin
Eddy Vluggen7-Jul-14 7:15
professionalEddy Vluggen7-Jul-14 7:15 
AnswerRe: Detect when iOS or Android connected to PC Pin
jschell7-Jul-14 10:04
jschell7-Jul-14 10:04 
GeneralRe: Detect when iOS or Android connected to PC Pin
EYESTRA1N17-Jul-14 8:33
EYESTRA1N17-Jul-14 8:33 
GeneralAn unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll Pin
ganeshmyname28-Jun-14 6:39
ganeshmyname28-Jun-14 6:39 
GeneralRe: An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll Pin
Dave Kreskowiak28-Jun-14 9:57
mveDave Kreskowiak28-Jun-14 9:57 
GeneralRe: An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll Pin
jinzai17-Jul-14 1:46
jinzai17-Jul-14 1:46 
QuestionExchange 2010 - Out Of Office Rule Pin
Frosch1111123-Jun-14 4:39
Frosch1111123-Jun-14 4:39 
AnswerRe: Exchange 2010 - Out Of Office Rule Pin
Eddy Vluggen23-Jun-14 4:59
professionalEddy Vluggen23-Jun-14 4:59 
GeneralRe: Exchange 2010 - Out Of Office Rule Pin
Frosch1111123-Jun-14 9:02
Frosch1111123-Jun-14 9:02 
AnswerRe: Exchange 2010 - Out Of Office Rule Pin
Eddy Vluggen23-Jun-14 22:29
professionalEddy Vluggen23-Jun-14 22:29 
GeneralRe: Exchange 2010 - Out Of Office Rule Pin
Frosch1111124-Jun-14 21:08
Frosch1111124-Jun-14 21:08 
GeneralRe: Exchange 2010 - Out Of Office Rule Pin
Eddy Vluggen24-Jun-14 22:29
professionalEddy Vluggen24-Jun-14 22:29 
GeneralRe: Exchange 2010 - Out Of Office Rule Pin
Frosch1111124-Jun-14 22:53
Frosch1111124-Jun-14 22:53 
AnswerRe: Exchange 2010 - Out Of Office Rule Pin
Bernhard Hiller23-Jun-14 21:46
Bernhard Hiller23-Jun-14 21:46 
QuestionRunning Shared sub in new thread? Pin
Draco201321-Jun-14 6:11
Draco201321-Jun-14 6:11 
AnswerRe: Running Shared sub in new thread? Pin
Dave Kreskowiak21-Jun-14 6:47
mveDave Kreskowiak21-Jun-14 6:47 
General[Hiring] .Net Developer in NYC Pin
Victoria F19-Jun-14 10:32
Victoria F19-Jun-14 10:32 
GeneralRe: [Hiring] .Net Developer in NYC Pin
Dave Kreskowiak19-Jun-14 10:48
mveDave Kreskowiak19-Jun-14 10:48 
GeneralRe: [Hiring] .Net Developer in NYC Pin
Victoria F19-Jun-14 10:49
Victoria F19-Jun-14 10:49 
GeneralRe: [Hiring] .Net Developer in NYC Pin
Dave Kreskowiak19-Jun-14 10:51
mveDave Kreskowiak19-Jun-14 10:51 
GeneralRe: [Hiring] .Net Developer in NYC Pin
Victoria F19-Jun-14 10:53
Victoria F19-Jun-14 10:53 
GeneralRe: [Hiring] .Net Developer in NYC Pin
Eddy Vluggen20-Jun-14 0:32
professionalEddy Vluggen20-Jun-14 0:32 
Questionentity framework 6 don't resolve foreign key Pin
micheleroma16-Jun-14 22:31
micheleroma16-Jun-14 22:31 
Hi,

I have four related tables
AttoreTipo (1..n) Attore (1..n) CommessaAttore (n..1) Commessa.

AttoreTipo is a lookup table

i'm using entityframework 6 code first with repository and UnitOfWork patterns.

the model is:

C#
public class Attore
{

    public int Id { get; set; }
    public int IdTipo { get; set; }
    public string Nome { get; set; }
    public string Cognome { get; set; }

    public virtual ICollection<CommessaAttore> CommessaAttore { get; set; }

    public virtual AttoreTipo AttoreTipo { get; set; }

}



C#
public class AttoreTipo
    {

        public int Id { get; set; }
        public string Tipo { get; set; }
        public DateTime CreateDate { get; set; }
        public DateTime? UpdateDate { get; set; }

        public virtual ICollection<Attore> Attore { get; set; }

    }


C#
public class CommessaAttore
  {

      public int Id { get; set; }
      public int IdCommessa { get; set; }
      public int IdAttore { get; set; }
      public DateTime CreateDate { get; set; }
      public DateTime? UpdateDate { get; set; }
      public virtual Commessa Commessa { get; set; }
      public virtual Attore Attore { get; set; }


  }


XML
public class Commessa
   {
       public int Id { get; set; }

       public string Descrizione { get; set; }

       public DateTime EndDate { get; set; }

       public DateTime CreateDate { get; set; }

       public DateTime? UpdateDate { get; set; }

       public virtual ICollection<CommessaAttore> CommessaAttore { get; set; }
 
   }



In the aspx page, in the same button click event, i call the repository's method AddCommessaAttore(CommessaAttore commessaattore)
,where CommessaAttore has the attore property value by an Attore entity. Attore entity has an attoretipo prop. (attoretipo entity) not set because is a lookup table. Next i call getCommessaAttoriByCommessaId method, that read all commessaattore records by a given idcommessa, to fill a gridview,

but the AttoreTipo result always null. Entity framework don't resolve AttoreTipo entity


C#
public CommessaAttore AddCommessaAttore(CommessaAttore commessaattore)
     {
         repository.Add(commessaattore);
         SaveChanges();
         return commessaattore;
     }



C#
public IEnumerable<CommessaAttore> GetCommessaAttoriByCommessaId(int idcommessa)
{
    var activities = repository.GetMany(commatts => commatts.IdCommessa == idcommessa);
    return activities;
}




thanks
AnswerRe: entity framework 6 don't resolve foreign key Pin
Eddy Vluggen17-Jun-14 7:36
professionalEddy Vluggen17-Jun-14 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.