public GenericRepository(RepoContext context, IPrincipalSecurityConcern security) { _context = context; _dbSet = context.Set <TModel>(); _dbQuery = context.Set <TModel>(); _security = security; }
public IActionResult Get(string deep) { var players = ctx.Set <Player>(); var accounts = ctx.Set <Account>(); var tokens = ctx.Set <Token>(); List <object> results = new List <object>(); foreach (Account account in accounts) { results.Add(new { First = account.First, Last = account.Last, Email = account.Email, players = players .Where(p => p.AccountId == account.Id) .Select(p => new { PlayerId = p.Id, GamerTag = p.GamerTag, Tokens = tokens .Where(tok => tok.PlayerId == p.Id) .Select(tok => new { TokenId = tok.Id, Name = tok.Name, Class = tok.Class, Identifier = tok.Identifier }).ToList() }) .ToList() }); } // Return a deep list... return(new ObjectResult(results)); }
public IList <LookupModel> GetAll <TModel>(int?parentId = null) where TModel : LookupModel { return(_mapper.Map <List <LookupModel> >(_context.Set <TModel>().Where(x => !x.Deleted && (parentId == null || x.ParentId == parentId)).ToList())); }
public virtual TEntity GetById(IdType id) { var entity = _context.Set <TEntity>().Find(id); return(entity); }
public IActionResult Get(string drill, int max) { bool getToken = drill.ToLower() == "token"; bool getAccount = drill.ToLower() == "account"; bool getPlayer = getAccount || getToken || drill.ToLower() == "player"; bool getTeam = getPlayer || drill.ToLower() == "team"; var games = ctx.Set <Game>(); var players = ctx.Set <Player>(); var tokens = ctx.Set <Token>(); var teams = ctx.Set <Team>(); var accounts = ctx.Set <Account>(); List <object> results = new List <object>(); foreach (Game game in games) { if (--max == 0) { break; } results.Add(new { GameId = game.Id, ServerIpAddress = game.ServerAddress, GameTitle = game.Title, Teams = teams .Where(t => t.GameId == game.Id && getTeam) .Select(t => new { TeamId = t.Id, TeamName = t.Name, TeamPlayers = players .Where(p => p.TeamId == t.Id && getPlayer) .Select(p => new { PlayerId = p.Id, GamerTag = p.GamerTag, Account = accounts .Where(a => a.Id == p.AccountId && getAccount) .Select(a => new { AccountId = a.Id, FirstName = a.First, LastName = a.Last, Email = a.Email, GamerTags = players .Where(alias => alias.AccountId == a.Id) .Select(alias => alias.GamerTag) .ToList() }).SingleOrDefault(), Tokens = tokens .Where(tok => tok.PlayerId == p.Id & getToken) .Select(tok => new { TokenId = tok.Id, Name = tok.Name, Class = tok.Class, Identifier = tok.Identifier }).ToList() }).ToList() }).ToList() }); } // Return a deep list... return(new ObjectResult(results)); }
public DataController(RepoContext ctx) { Context = ctx; DbSet = ctx.Set <T>(); }