Skip to content
Advertisement

c# How to dapperRow to strongly typed object displayed in grid view

I am sure i have not the best practice solution like the most of u guys could program, but im new in the business so pls give me a chance πŸ˜›

i created a table in my sqlite database and added a Employee to the Employee table. I Set the DataContext of my GridView to the returned List from my ModelView. But my grid is emtpy. i guess i have a logical error in the art i convert my dapperRow. Please take a look at it. i Dont get an error or something. My gridView is just empty.

Advertisement

Answer

Here’s what your Dapper code should look like for retrieving all employees:

That’s it. You can find out more about the GetAll<T>() method here.

Your Insert Employee code looks OK, but all you really need to do is:

You will need to properly annotate your Employee class to make this work correctly. The Dapper.Contrib page I linked above explains how to do this.

For MVVM, I suggest a good tutorial, like this one.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement