ajhampson (17) [Avatar] Offline
Hi Dustin,

I'm really enjoying the book! Working through the examples in Version 5, I had a little difficulty with the DapperDI project in Chapter 6.

When I tried to build the SqliteDal project, I got the following error:
CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert

After some searching, I found the solution was to add:
    <PackageReference Include="Microsoft.CSharp" Version="4.3.0" />

to the SqliteDal.csproj file.

Also, when running the test the first time, I had this error:
[xUnit.net 00:00:01.2438606]         C:\Users\hampson\Documents\DevelWork\dotnetcore\Meap_4\DapperDI\SqliteBlogTest\UnitTest1.cs(32,0): at SqliteBlogTest.UnitTest1.Test1()
[xUnit.net 00:00:01.2608256]   Finished:    SqliteBlogTest
Failed   SqliteBlogTest.UnitTest1.Test1
Error Message:
 System.InvalidOperationException : Must add values for the following parameters: @IsPublished, @PublishDate, @Title, @PermaLinkTitle, @Description, @ContentUri, @ContentType
Stack Trace:
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior)
   at Dapper.SqlMapper.<QueryImpl>d__124`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType)
   at Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType)
   at SqliteDal.SqliteBlogContext.InsertPost(Post post) in C:\Users\hampson\Documents\DevelWork\dotnetcore\Meap_4\DapperDI\SqliteDal\SqliteBlogContext.cs:line 26
   at SqliteBlogTest.UnitTest1.Test1() in C:\Users\hampson\Documents\DevelWork\dotnetcore\Meap_4\DapperDI\SqliteBlogTest\UnitTest1.cs:line 32

Total tests: 1. Passed: 0. Failed: 1. Skipped: 0.
Test Run Failed.
Test execution time: 2.3039 Seconds

The solution for this is to change the Test1() method where it creates a new Post to:
            var post = new Post() {
                Title = "Test Title 1",
                PermaLinkTitle = "TestBlog1",
                Description = "Test Description 1",
                ContentUri = "./test1.html",
                ContentType = "HTML",
                PublishDate = DateTime.Now,
                IsPublished = false

so that it populates the whole object.

I'm thinking you probably already found and fixed these, but in case you haven't I wanted to post them.

I've been enjoying the book and the examples are great. I know from my own experience that finding good simple coding examples can be a pain.

Thanks and sorry for the long post!

Dustin Metzgar (19) [Avatar] Offline
Thanks Alan! Part of the feedback for chapters 5 & 6 was that the intro didn't match the example. I ended up rewriting these chapters with an example that matches the intro. It should get pushed to MEAP soon. Let me know what you think.