Skip to content

DbProvider Operations

Chase Florell edited this page May 7, 2017 · 1 revision

The core PCL library FutureState.AppCore.Data contains some methods for basic CRUD operations.

Create

var jill = new StudentModel
    {
        Id = StudentJillId,
        FirstName = "Jill",
        LastName = "",
        Email = JillEmail,
        Courses = new List<CourseModel> { englishCourse },
    };

_dbProvider.Create( jill );

Read

IList<StudentModel> allStudents = _dbProvider.Query<StudentModel>().Select().ToList();
StudentModel jill = _dbProvider.Query<StudentModel>().Where(s => s.Email == "JillEmail").Select().FirstOrDefault();

Update

jill.Email = "JillNewEmail";
_dbProvider.Update<StudentModel>(jill);

Delete
note: this is still a work in progress

// first flavor
_dbProvider.Query<StudentModel>().Where( s => s.Email == "JillNewEmail" ).Delete();

// second flavor
_dbProvider.Delete<StudentModel>(s => s.Email == "JillNewEmail");
Clone this wiki locally