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

.NET (Core and Framework)

 
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 
GeneralRe: entity framework 6 don't resolve foreign key Pin
micheleroma19-Jun-14 9:18
micheleroma19-Jun-14 9:18 
GeneralRe: entity framework 6 don't resolve foreign key Pin
Eddy Vluggen20-Jun-14 8:09
professionalEddy Vluggen20-Jun-14 8:09 
AnswerRe: entity framework 6 don't resolve foreign key Pin
Nathan Minier29-Jul-14 6:07
professionalNathan Minier29-Jul-14 6:07 
QuestionHow to make FolderBrowserDialog in asp.net Pin
ven75311-Jun-14 20:54
ven75311-Jun-14 20:54 
AnswerRe: How to make FolderBrowserDialog in asp.net Pin
Richard MacCutchan11-Jun-14 21:25
mveRichard MacCutchan11-Jun-14 21:25 
AnswerRe: How to make FolderBrowserDialog in asp.net Pin
Pete O'Hanlon11-Jun-14 22:18
mvePete O'Hanlon11-Jun-14 22:18 
QuestionHow to get 32-bit .NET Framework InstallPath on a 64-bit machine? Pin
Frank W. Wu10-Jun-14 6:11
Frank W. Wu10-Jun-14 6:11 
AnswerRe: How to get 32-bit .NET Framework InstallPath on a 64-bit machine? Pin
Richard Deeming10-Jun-14 6:41
mveRichard Deeming10-Jun-14 6:41 
GeneralRe: How to get 32-bit .NET Framework InstallPath on a 64-bit machine? Pin
Frank W. Wu10-Jun-14 6:50
Frank W. Wu10-Jun-14 6:50 
GeneralRe: How to get 32-bit .NET Framework InstallPath on a 64-bit machine? Pin
Richard Deeming10-Jun-14 7:03
mveRichard Deeming10-Jun-14 7:03 
Questioninsertion based on a condition Pin
Member 103249748-Jun-14 9:39
Member 103249748-Jun-14 9:39 
AnswerRe: insertion based on a condition Pin
Richard MacCutchan8-Jun-14 21:54
mveRichard MacCutchan8-Jun-14 21:54 
Question[VB.NET 2008] How to use OpenNETCF.Net.Mail? Pin
steve_94966135-Jun-14 22:57
professionalsteve_94966135-Jun-14 22:57 
AnswerRe: [VB.NET 2008] How to use OpenNETCF.Net.Mail? Pin
steve_949661329-Jun-14 23:19
professionalsteve_949661329-Jun-14 23:19 
Question[VB.NET 2008] How to rise an event of an object in a form from another form Pin
steve_94966134-Jun-14 4:52
professionalsteve_94966134-Jun-14 4:52 
AnswerRe: [VB.NET 2008] How to rise an event of an object in a form from another form Pin
Dave Kreskowiak4-Jun-14 7:10
mveDave Kreskowiak4-Jun-14 7:10 

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.