SQLite net PCL - Simple select

前端 未结 2 1564
遇见更好的自我
遇见更好的自我 2021-02-20 09:40

I use SQLite from windows app and now I am developing in Xamarin a portable app so I am using the plugin sqlite net pcl and I am having great trouble to understand how it works.

2条回答
  •  忘了有多久
    2021-02-20 10:34

    The accepted answer doesn't really help if you have a custom mapping for the tables name. The "Sql" table name can be found at runtime accessing to the type mapping.

    Here an extension method

    public static class NativeConnectionExtension
    {
        public static List SelectAllFrom(this SQLiteConnection cnn) where T : new()
        {
            var mapping = cnn.GetMapping();
            var result = cnn.Query(String.Format("select * from {0};", mapping.TableName));
            return result;
        }
    }
    

提交回复
热议问题