Click here to Skip to main content
15,892,746 members
Home / Discussions / C#
   

C#

 
AnswerRe: Password Regex Help Pin
Bohdan Stupak19-Apr-23 3:28
professionalBohdan Stupak19-Apr-23 3:28 
Questioncreate our own unit testing framework in C# Pin
Sakhalean26-Mar-23 18:32
Sakhalean26-Mar-23 18:32 
AnswerRe: create our own unit testing framework in C# Pin
OriginalGriff26-Mar-23 21:00
mveOriginalGriff26-Mar-23 21:00 
AnswerRe: create our own unit testing framework in C# Pin
jschell27-Mar-23 7:00
jschell27-Mar-23 7:00 
AnswerRe: create our own unit testing framework in C# Pin
Gerry Schmitz27-Mar-23 11:39
mveGerry Schmitz27-Mar-23 11:39 
GeneralRe: create our own unit testing framework in C# Pin
mtoha13-Apr-23 16:39
professionalmtoha13-Apr-23 16:39 
QuestionManagement of window coordinates and sizes for multiple screens of different resolutions Pin
temuco25-Mar-23 13:14
professionaltemuco25-Mar-23 13:14 
AnswerRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
OriginalGriff25-Mar-23 20:18
mveOriginalGriff25-Mar-23 20:18 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
temuco26-Mar-23 1:22
professionaltemuco26-Mar-23 1:22 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
Dave Kreskowiak26-Mar-23 5:38
mveDave Kreskowiak26-Mar-23 5:38 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
temuco26-Mar-23 22:28
professionaltemuco26-Mar-23 22:28 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
Dave Kreskowiak27-Mar-23 1:30
mveDave Kreskowiak27-Mar-23 1:30 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
temuco27-Mar-23 21:18
professionaltemuco27-Mar-23 21:18 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
Gerry Schmitz26-Mar-23 7:57
mveGerry Schmitz26-Mar-23 7:57 
QuestionEntity Framework Code First - two Foreign Keys from same table Pin
Alex Dunlop21-Mar-23 8:43
Alex Dunlop21-Mar-23 8:43 
AnswerRe: Entity Framework Code First - two Foreign Keys from same table Pin
Gerry Schmitz21-Mar-23 9:30
mveGerry Schmitz21-Mar-23 9:30 
AnswerRe: Entity Framework Code First - two Foreign Keys from same table Pin
jschell23-Mar-23 6:04
jschell23-Mar-23 6:04 
AnswerRe: Entity Framework Code First - two Foreign Keys from same table Pin
Richard Deeming27-Mar-23 0:35
mveRichard Deeming27-Mar-23 0:35 
You can't use the same collection navigation property to represent the requests where the user is the sender and the requests where the user is the target.

You also can't use the RequestId property as the foreign key to the users table - you're not creating a one-to-one relationship, so the request ID and the user ID will be different.
C#
public class User
{
    ...
    public List<Request> SentRequests { get; set; }
    public List<Request> ReceivedRequests { get; set; }
    ...
}

...

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Request>()
                .HasOne(m => m.SenderUserRef)
                .WithMany(t => t.SentRequests)
                .OnDelete(DeleteBehavior.Restrict);

    modelBuilder.Entity<Request>()
                .HasOne(m => m.TargetUserRef)
                .WithMany(t => t.ReceivedRequests)
                .OnDelete(DeleteBehavior.Restrict);
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

QuestionHow to highlight all rows in listbox between two index values? Pin
Member 1405587917-Mar-23 1:25
Member 1405587917-Mar-23 1:25 
AnswerRe: How to highlight all rows in listbox between two index values? Pin
Pete O'Hanlon17-Mar-23 1:33
mvePete O'Hanlon17-Mar-23 1:33 
AnswerRe: How to highlight all rows in listbox between two index values? Pin
RedDk17-Mar-23 6:26
RedDk17-Mar-23 6:26 
QuestionMessage Closed Pin
15-Mar-23 20:32
Sivanujan Sivaraja15-Mar-23 20:32 
AnswerRe: Serial port listening application Pin
OriginalGriff15-Mar-23 21:02
mveOriginalGriff15-Mar-23 21:02 
GeneralRe: Serial port listening application Pin
Richard MacCutchan15-Mar-23 22:34
mveRichard MacCutchan15-Mar-23 22:34 
GeneralRe: Serial port listening application Pin
OriginalGriff15-Mar-23 22:41
mveOriginalGriff15-Mar-23 22:41 

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.