Click here to Skip to main content
15,887,898 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more: , +
I have the following model of the claim one player makes on another player after winning a bet:
C#
public class Claim : BaseMovement
{
    public virtual ApplicationUser Source { get; set; }
    public virtual string SourceId { get; set; }
    public virtual ApplicationUser Destination { get; set; }
    public virtual string DestinationId { get; set; }
    public virtual int Amount { get; set; }
    public DateTime? TimePaid { get; set; }
}


The Source is the originator of the claim, the Destination their debtor, or 'target'. Once payment is confirmed, the claim has a non-null TimePaid value.

Oh yes, our players are a tiny and quite irrelevant extension to the ApplicationUser provided by the MVC project template, but copied here because someone always wants 'more code!'

C#
public class ApplicationUser : IdentityUser, IBaseEntity
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        return userIdentity;
    }

    public string FullName { get; set; }
    public int Balance { get; set; }
}

Only the two declared properties are my fine craftsmanship. And ApplicationUser the only source. IdentityUser and IpreEntityntity are part of an unholy library with a namespace of Microsoft.AspNet.Identity.EntityFramework.

Now I must 'tally', per player, in this p.o.v. the source, assuming most claims are valid and those paid are safer to assume valid, their biggest win and total winnings. I am tired, used LINQ grouping about twice ever, and need a hand with this please.
Posted
Updated 3-Nov-15 7:40am
v2
Comments
Maciej Los 3-Nov-15 14:36pm    
Seems very interesting, so i voted 5 for the question, but... you didn't show us a method you tried (to group data). Could you be so kind...?
Brady Kelly 3-Nov-15 15:00pm    
I'm asking how to group the data, using a LINQ query (to entities or objects) because I have no idea where to start. I'm currently just using a loop over a few selects and manually grouping.
Maciej Los 11-Apr-17 15:35pm    
Have you solved your issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900