public IList <T> GetBy <T>(string appid, string id) { var mongodb = MongoDBHelper.GetMongoDB(); var collection = mongodb.GetCollection <T>(_colname); FilterDefinition <T> wheres = Builders <T> .Filter.Eq("AppId", appid); if (!string.IsNullOrWhiteSpace(id)) { wheres = wheres & Builders <T> .Filter.Eq("Id", id); } return(collection.Find <T>(wheres).ToList <T>()); }