public IEnumerable <Triathlon> GetTri(string id, string dateS, string dateE, string place) { int i = 0; var qc = new IMongoQuery[4]; if (id != "") { qc[i++] = Query <Triathlon> .EQ(p => p.Id, new ObjectId(id)); } if (dateS != "") { qc[i++] = Query <Triathlon> .GTE(p => p.date, dateS); } if (dateE != "") { qc[i++] = Query <Triathlon> .LTE(p => p.date, dateE); } if (place != "") { qc[i++] = Query <Triathlon> .Matches(p => p.place, place); } qc = qc.Where(c => c != null).ToArray(); if (qc.Length > 0) { return(_db.GetCollection <Triathlon>("Triathlon").Find(Query.And(qc))); } else { return(_db.GetCollection <Triathlon>("Triathlon").FindAll()); } }