Add LiteDb in all repositories
This commit is contained in:
@@ -1,11 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Data.Interface;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Data
|
||||
{
|
||||
public class GearRepository : IGearRepository
|
||||
{
|
||||
public IEnumerable<Gear> GetAllGears()
|
||||
{
|
||||
IEnumerable<Gear> result = new List<Gear>();
|
||||
|
||||
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
||||
{
|
||||
var col = db.GetCollection<Gear>("Gear");
|
||||
|
||||
result = col.FindAll().ToList();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Gear GetGearById(int id)
|
||||
{
|
||||
Gear result;
|
||||
|
||||
using (var db = new LiteDatabase(@".\Data\MyData.db"))
|
||||
{
|
||||
var col = db.GetCollection<Gear>("Gear");
|
||||
|
||||
result = col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user