ISQLitePlatform in SQLConnection method

Issue #28 invalid
piotrek1231 created an issue

Hi, I used to sqlite-net and I had created connection using: _sqlLiteConnection = new SQLiteConnection(_pathOfDatabase);

After install sqlite-net extension SQLiteConnection require two parameters. What I should set as the first parameter ?

Thanks

Comments (22)

  1. Guillermo Gutiérrez

    In the SQLite-Net PCL version (https://github.com/oysteinkrog/SQLite.Net-PCL), you have to pass the platform implementation to the SQLiteConnection constructor.

    That object is declared in the platform nuget package. For example, for Windows Phone projects you have to include this package: https://www.nuget.org/packages/SQLite.Net.Platform.WindowsPhone8/

    If you need more info, please ask in the SQLite-Net PCL project: https://github.com/oysteinkrog/SQLite.Net-PCL

  2. piotrek1231 reporter

    Thanks for reply. Unfortunately SQLite-net PCL not support WP 8.1. Is any way to use sqlite net extension without sqlite-net PCL ?

  3. piotrek1231 reporter

    When I installed SQLite-Net Extension PCL it added also SQLIte-Net PCL. Could you confirm that my way is right ?

    1. Uninstall SQLIte-Net PCL and SQLite-Net Extension PCL
    2. Install SQLIte-Net (not PCL)
    3. Add to my solution this project
  4. Guillermo Gutiérrez

    Yes, that should work. I don't know which reflection API you have for WP81, but If you find issues with the reflection API try using the version 1.1.1 of the code.

  5. piotrek1231 reporter

    I added version 1.1.1 to my project. There were many errors connected with json.net and sqllite-net pcl, so I reinstall json.net and I wanted to reinstall sqlite-net PCL, but ... "Could not install package 'SQLite.Net-PCL 2.4.1'. You are trying to install this package into a project that targets 'portable-net45+sl50+win+wp80', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author." In this situation I installed sqlite-net (without PCL), but there are 5 errors connected with this line: "

    var relationshipAttribute = relationshipProperty.GetAttribute<RelationshipAttribute>();"
    

    Error: The type 'SQLiteNetExtensions.Attributes.RelationshipAttribute' cannot be used as type parameter 'T' in the generic type or method 'SQLiteNetExtensions.Extensions.ReflectionExtensions.GetAttribute<T>(System.Reflection.PropertyInfo)'. There is no implicit reference conversion from 'SQLiteNetExtensions.Attributes.RelationshipAttribute' to 'System.Attribute'.

    Thanks

  6. Guillermo Gutiérrez

    Did you add the project itself or copied the sources?

    These are the steps that you should follow to get it working:

    • Add your platform-specific SQLite-Net library to your project
    • Make sure that it works (try inserting any simple object)
    • Add JSON.Net dependency (it's required by SQLite-Net Extensions for TextBlob attributes)
    • Copy the sources of SQLite-Net Extensions (adding the project as a reference won't work!)

    Try this and tell me how it goes.

  7. piotrek1231 reporter

    I had copied project, but now I have sourceds added to my project. I develop Universal App, so I install in Windows 8.1 App SQLite-Net and Json.Net. Next, I copied sources from "Attributes", "Exceptions" and "Extensions" to my Shared project. It looks like: bitbucket - sqlite extensions.PNG

    All is right, because for example OneToMany is recognized, but if I use:

    _sqlLiteConnection.InsertWithChildren(object); 
    

    I get error: SQLite.SQLiteConnection' does not contain a definition for 'InsertWithChildren' and no extension method 'InsertWithChildren' accepting a first argument of type 'SQLite.SQLiteConnection' could be found (are you missing a using directive or an assembly reference?

  8. Guillermo Gutiérrez

    If you haven't changed the namespaces, you need to add the following using directive:

    using SQLiteNetExtensions.Extensions;
    
  9. piotrek1231 reporter

    Thanks, it caused by this namespace (VS didn't prompt using this namespace). But now I have a some problems with reflections:

    1. 'System.Type' does not contain a definition for 'GetProperties' and no extension method 'GetProperties' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)

    2. The name 'BindingFlags' does not exist in the current context

    Do you know how I can resolve this issue ?

  10. piotrek1231 reporter

    Can I replace

    type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
    

    by

    type.GetRuntimeProperties()
    

    ?

  11. piotrek1231 reporter

    Unfortunately, I can't find equivalent to: 1. type.GetCustomAttributes(typeof(T), true); 2. foreignKeyAttribute.ForeignType.IsAssignableFrom(destinationType) 3. elementType.IsAssignableFrom(inverseType))

    etc

  12. Guillermo Gutiérrez

    Just take the last version of the code. I think that the new reflection API is WP81 compatible

  13. Guilherme Minglini

    Guillermo, Im trying to use SQLite-Net Extensions in a Windows Phone 8.1 app (it is NOT Windows Phone 8.1 Silverlight). I don´t know which version i should use.

    If i install the SQLite-Net Extensions-PCL, my SQLConnection class needs two parameters. In the examples, SQLConnection receive the database name as the only parameter. What im doing wrong?

  14. Guilherme Minglini

    @redent Thanks. With the WinRT platform, It is right to create a new SQLConnection like this?

    new SQLiteConnection(new SQLitePlatformWinRT(), DATABASE_PATH);
    

    And using the sources of the WinRT platform, i can continue to use the SQLiteNetExtensionsAsync dll, right?

  15. Guillermo Gutiérrez

    @minglini Yes. The platform is only required to instantiate the connection in the platform-specific code. The rest of the code goes into the shared PCL code.

  16. Guilherme Minglini

    @redent Im getting this exception when trying to create a new SQLiteConnection:

    An exception of type 'System.DllNotFoundException' occurred in mscorlib.ni.dll but was not handled in user code

    Additional information: Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

    My SQLite references: references.png

    Can you help me?

  17. Guillermo Gutiérrez

    @minglini Probably you didn't install sqlite Visual Studio extension. I'm afraid I cannot be much more useful, I'm not really used to WP8.1 and this is not related to this project at all. You may have more luck asking in the SQLite.Net PCL project page or in StackOverflow.

    Once you get SQLite-Net working, SQLite-Net Extensions should work.

  18. Guilherme Minglini

    @redent That was it. It is now working. Thanks for the help with the sources of the WinRT platform!

  19. Log in to comment