public List <ANSWER> GetAnswersForParty(int partyId)
 {
     using (ElectionSqliteContext ctx = new ElectionSqliteContext())
     {
         return(ctx.ANSWERs.Where(d => d.PARTY == partyId).ToList());
     }
 }
Beispiel #2
0
 public void AddParty(PARTY newParty)
 {
     using (var ctx = new ElectionSqliteContext())
     {
         ctx.PARTies.Add(newParty);
         ctx.SaveChanges();
     }
 }
 public List <DbParty> GetPartiesFilter(int?id, string nameShort, string nameLong)
 {
     using (var ctx = new ElectionSqliteContext())
     {
         return(ctx.PARTies.Where(d => (d.ID == id || id == null) &&
                                  (d.NAME_SHORT == nameShort ||
                                   string.IsNullOrEmpty(nameShort)) &&
                                  (d.NAME_LONG == nameLong ||
                                   string.IsNullOrEmpty(nameLong))).ToList());
     }
 }
        public ICollection <DbParty> GetParties()
        {
            ICollection <DbParty> retList = new Collection <DbParty>();

            using (var ctx = new ElectionSqliteContext())
            {
                // since the context gets disposed, before the navigation attributes are queried,
                // all elements have to be added manually at this point, hence this stupid function..
                retList = getParties(ctx.PARTies.ToList());
            }

            return(retList);
        }