Sqlite cannot find class when creating tableWhen should you use a class vs a struct in C++?How to list the tables in a SQLite database file that was opened with ATTACH?When to use static classes in C#Finding duplicate values in a SQL tableWhen is it appropriate to use C# partial classes?Find all tables containing column with specified name - MS SQL ServerWhat does “Could not find or load main class” mean?Why not inherit from List<T>?sqlite create statement for composition classXamarin.Forms SQLite exception - don't know about <Custom Class>

Why is the principal energy of an electron lower for excited electrons in a higher energy state?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

How to preserve electronics (computers, iPads and phones) for hundreds of years

Why does a 97 / 92 key piano exist by Bösendorfer?

Storage of electrolytic capacitors - how long?

Alignment of six matrices

Proving an identity involving cross products and coplanar vectors

Why is participating in the European Parliamentary elections used as a threat?

Animation: customize bounce interpolation

Why is the sun approximated as a black body at ~ 5800 K?

Telemetry for feature health

Do I have to know the General Relativity theory to understand the concept of inertial frame?

What is the meaning of "You've never met a graph you didn't like?"

Pre-Employment Background Check With Consent For Future Checks

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

Would a primitive species be able to learn English from reading books alone?

How to make a list of partial sums using forEach

If A is dense in Q, then it must be dense in R.

Make a Bowl of Alphabet Soup

Grepping string, but include all non-blank lines following each grep match

SOQL query causes internal Salesforce error

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Do I have to take mana from my deck or hand when tapping a dual land?

Confusion over Hunter with Crossbow Expert and Giant Killer



Sqlite cannot find class when creating table


When should you use a class vs a struct in C++?How to list the tables in a SQLite database file that was opened with ATTACH?When to use static classes in C#Finding duplicate values in a SQL tableWhen is it appropriate to use C# partial classes?Find all tables containing column with specified name - MS SQL ServerWhat does “Could not find or load main class” mean?Why not inherit from List<T>?sqlite create statement for composition classXamarin.Forms SQLite exception - don't know about <Custom Class>













1















I have two classes, Event and ScoutData



public class Event

[PrimaryKey]
public int ID

get; set;


public Event()


public Event(string start, string end, string name, int id, bool isCurrent)

startDate = start;
endDate = end;
eventName = name;
ID = id;
isCurrentEvent = isCurrent;


public string startDate

get; set;

public string endDate

get; set;

public string eventName

get; set;


public bool isCurrentEvent

get; set;



public class ScoutData

[PrimaryKey]
public int ID get; set;

public ScoutData()



// Some public properties, including a public Event from the other class



When I try to add tables to the sqlite connection



public EventDatabase()

_connection = DependencyService.Get<ISQLite>().GetConnection();
_connection.CreateTable<ScoutData>();
_connection.CreateTable<Event>();



The Event table generates fine, but the ScoutData table throws this exception:




System.NotSupportedException: Don't know about App6.Event




Class ScoutData uses Event inside of it, but everything is public. I've tried renaming, cleaning, etc but can't seem to figure out why sqlite will create tables for some classes but not others.










share|improve this question



















  • 2





    SQLite.NET only handles primitive .NET types. What you're trying to do is essentially create a FK relation between two tables. There is a separate SQLite Extensions packages that enables you to do this.

    – Jason
    Mar 7 at 3:28















1















I have two classes, Event and ScoutData



public class Event

[PrimaryKey]
public int ID

get; set;


public Event()


public Event(string start, string end, string name, int id, bool isCurrent)

startDate = start;
endDate = end;
eventName = name;
ID = id;
isCurrentEvent = isCurrent;


public string startDate

get; set;

public string endDate

get; set;

public string eventName

get; set;


public bool isCurrentEvent

get; set;



public class ScoutData

[PrimaryKey]
public int ID get; set;

public ScoutData()



// Some public properties, including a public Event from the other class



When I try to add tables to the sqlite connection



public EventDatabase()

_connection = DependencyService.Get<ISQLite>().GetConnection();
_connection.CreateTable<ScoutData>();
_connection.CreateTable<Event>();



The Event table generates fine, but the ScoutData table throws this exception:




System.NotSupportedException: Don't know about App6.Event




Class ScoutData uses Event inside of it, but everything is public. I've tried renaming, cleaning, etc but can't seem to figure out why sqlite will create tables for some classes but not others.










share|improve this question



















  • 2





    SQLite.NET only handles primitive .NET types. What you're trying to do is essentially create a FK relation between two tables. There is a separate SQLite Extensions packages that enables you to do this.

    – Jason
    Mar 7 at 3:28













1












1








1








I have two classes, Event and ScoutData



public class Event

[PrimaryKey]
public int ID

get; set;


public Event()


public Event(string start, string end, string name, int id, bool isCurrent)

startDate = start;
endDate = end;
eventName = name;
ID = id;
isCurrentEvent = isCurrent;


public string startDate

get; set;

public string endDate

get; set;

public string eventName

get; set;


public bool isCurrentEvent

get; set;



public class ScoutData

[PrimaryKey]
public int ID get; set;

public ScoutData()



// Some public properties, including a public Event from the other class



When I try to add tables to the sqlite connection



public EventDatabase()

_connection = DependencyService.Get<ISQLite>().GetConnection();
_connection.CreateTable<ScoutData>();
_connection.CreateTable<Event>();



The Event table generates fine, but the ScoutData table throws this exception:




System.NotSupportedException: Don't know about App6.Event




Class ScoutData uses Event inside of it, but everything is public. I've tried renaming, cleaning, etc but can't seem to figure out why sqlite will create tables for some classes but not others.










share|improve this question
















I have two classes, Event and ScoutData



public class Event

[PrimaryKey]
public int ID

get; set;


public Event()


public Event(string start, string end, string name, int id, bool isCurrent)

startDate = start;
endDate = end;
eventName = name;
ID = id;
isCurrentEvent = isCurrent;


public string startDate

get; set;

public string endDate

get; set;

public string eventName

get; set;


public bool isCurrentEvent

get; set;



public class ScoutData

[PrimaryKey]
public int ID get; set;

public ScoutData()



// Some public properties, including a public Event from the other class



When I try to add tables to the sqlite connection



public EventDatabase()

_connection = DependencyService.Get<ISQLite>().GetConnection();
_connection.CreateTable<ScoutData>();
_connection.CreateTable<Event>();



The Event table generates fine, but the ScoutData table throws this exception:




System.NotSupportedException: Don't know about App6.Event




Class ScoutData uses Event inside of it, but everything is public. I've tried renaming, cleaning, etc but can't seem to figure out why sqlite will create tables for some classes but not others.







c# android sql class xamarin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 6:08









Dale Burrell

3,39152655




3,39152655










asked Mar 7 at 2:45









JuliaJulia

61




61







  • 2





    SQLite.NET only handles primitive .NET types. What you're trying to do is essentially create a FK relation between two tables. There is a separate SQLite Extensions packages that enables you to do this.

    – Jason
    Mar 7 at 3:28












  • 2





    SQLite.NET only handles primitive .NET types. What you're trying to do is essentially create a FK relation between two tables. There is a separate SQLite Extensions packages that enables you to do this.

    – Jason
    Mar 7 at 3:28







2




2





SQLite.NET only handles primitive .NET types. What you're trying to do is essentially create a FK relation between two tables. There is a separate SQLite Extensions packages that enables you to do this.

– Jason
Mar 7 at 3:28





SQLite.NET only handles primitive .NET types. What you're trying to do is essentially create a FK relation between two tables. There is a separate SQLite Extensions packages that enables you to do this.

– Jason
Mar 7 at 3:28












2 Answers
2






active

oldest

votes


















0














Like Jason said, if you use SQLite.Net Extensions you can do it like so :



public class Event

[PrimaryKey]
public int Id get; set;

// Need the foreign key here
[ForeignKey(typeof(ScoutData))]
public int ScoutDataId get; set;

public string startDate get; set;
public string endDate get; set;
public string eventName get; set;
public bool isCurrentEvent get; set;

public Event()



public Event(string start, string end, string name, int id, bool isCurrent)

startDate = start;
endDate = end;
eventName = name;
ID = id;
isCurrentEvent = isCurrent;



public class ScoutData

[PrimaryKey]
public int Id get; set;

// I don't know what relationship you are looking for but this is one to one:
[OneToOne(CascadeOperations = CascadeOperation.All)]
public Event Event get; set;

public ScoutData()



// Some public properties, including a public Event from the other class



Also if you are using async then use the async version here






share|improve this answer






























    0














    I would suggest to create a table ScoutDataEvent or so, to get a connection between the two tables.



    public class ScoutDataEvent

    [PrimaryKey]
    public int ID get; set;

    [NotNull]
    public int EventID get; set;

    [NotNull]
    public int ScoutDataID get; set;



    With this Table you can delete your public Event in the ScoutData-Table and call the Event-Table with the ScoutDataID. For Example :



    var sD = conn.Table<ScoutData>().FirstOrDefaultAsync().Result;
    var sDE = conn.Table<ScoutDataEvent>().Where(p => p.ScoutDataID == sD.ID).FirstOrDefaultAsync().Result;
    var event = conn.Table<Event>().Where(p => p.ID == sDE.EventID).FirstOrDefaultAsync().Result;





    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035258%2fsqlite-cannot-find-class-when-creating-table%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Like Jason said, if you use SQLite.Net Extensions you can do it like so :



      public class Event

      [PrimaryKey]
      public int Id get; set;

      // Need the foreign key here
      [ForeignKey(typeof(ScoutData))]
      public int ScoutDataId get; set;

      public string startDate get; set;
      public string endDate get; set;
      public string eventName get; set;
      public bool isCurrentEvent get; set;

      public Event()



      public Event(string start, string end, string name, int id, bool isCurrent)

      startDate = start;
      endDate = end;
      eventName = name;
      ID = id;
      isCurrentEvent = isCurrent;



      public class ScoutData

      [PrimaryKey]
      public int Id get; set;

      // I don't know what relationship you are looking for but this is one to one:
      [OneToOne(CascadeOperations = CascadeOperation.All)]
      public Event Event get; set;

      public ScoutData()



      // Some public properties, including a public Event from the other class



      Also if you are using async then use the async version here






      share|improve this answer



























        0














        Like Jason said, if you use SQLite.Net Extensions you can do it like so :



        public class Event

        [PrimaryKey]
        public int Id get; set;

        // Need the foreign key here
        [ForeignKey(typeof(ScoutData))]
        public int ScoutDataId get; set;

        public string startDate get; set;
        public string endDate get; set;
        public string eventName get; set;
        public bool isCurrentEvent get; set;

        public Event()



        public Event(string start, string end, string name, int id, bool isCurrent)

        startDate = start;
        endDate = end;
        eventName = name;
        ID = id;
        isCurrentEvent = isCurrent;



        public class ScoutData

        [PrimaryKey]
        public int Id get; set;

        // I don't know what relationship you are looking for but this is one to one:
        [OneToOne(CascadeOperations = CascadeOperation.All)]
        public Event Event get; set;

        public ScoutData()



        // Some public properties, including a public Event from the other class



        Also if you are using async then use the async version here






        share|improve this answer

























          0












          0








          0







          Like Jason said, if you use SQLite.Net Extensions you can do it like so :



          public class Event

          [PrimaryKey]
          public int Id get; set;

          // Need the foreign key here
          [ForeignKey(typeof(ScoutData))]
          public int ScoutDataId get; set;

          public string startDate get; set;
          public string endDate get; set;
          public string eventName get; set;
          public bool isCurrentEvent get; set;

          public Event()



          public Event(string start, string end, string name, int id, bool isCurrent)

          startDate = start;
          endDate = end;
          eventName = name;
          ID = id;
          isCurrentEvent = isCurrent;



          public class ScoutData

          [PrimaryKey]
          public int Id get; set;

          // I don't know what relationship you are looking for but this is one to one:
          [OneToOne(CascadeOperations = CascadeOperation.All)]
          public Event Event get; set;

          public ScoutData()



          // Some public properties, including a public Event from the other class



          Also if you are using async then use the async version here






          share|improve this answer













          Like Jason said, if you use SQLite.Net Extensions you can do it like so :



          public class Event

          [PrimaryKey]
          public int Id get; set;

          // Need the foreign key here
          [ForeignKey(typeof(ScoutData))]
          public int ScoutDataId get; set;

          public string startDate get; set;
          public string endDate get; set;
          public string eventName get; set;
          public bool isCurrentEvent get; set;

          public Event()



          public Event(string start, string end, string name, int id, bool isCurrent)

          startDate = start;
          endDate = end;
          eventName = name;
          ID = id;
          isCurrentEvent = isCurrent;



          public class ScoutData

          [PrimaryKey]
          public int Id get; set;

          // I don't know what relationship you are looking for but this is one to one:
          [OneToOne(CascadeOperations = CascadeOperation.All)]
          public Event Event get; set;

          public ScoutData()



          // Some public properties, including a public Event from the other class



          Also if you are using async then use the async version here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 11:30









          Iain SmithIain Smith

          5,97742846




          5,97742846























              0














              I would suggest to create a table ScoutDataEvent or so, to get a connection between the two tables.



              public class ScoutDataEvent

              [PrimaryKey]
              public int ID get; set;

              [NotNull]
              public int EventID get; set;

              [NotNull]
              public int ScoutDataID get; set;



              With this Table you can delete your public Event in the ScoutData-Table and call the Event-Table with the ScoutDataID. For Example :



              var sD = conn.Table<ScoutData>().FirstOrDefaultAsync().Result;
              var sDE = conn.Table<ScoutDataEvent>().Where(p => p.ScoutDataID == sD.ID).FirstOrDefaultAsync().Result;
              var event = conn.Table<Event>().Where(p => p.ID == sDE.EventID).FirstOrDefaultAsync().Result;





              share|improve this answer



























                0














                I would suggest to create a table ScoutDataEvent or so, to get a connection between the two tables.



                public class ScoutDataEvent

                [PrimaryKey]
                public int ID get; set;

                [NotNull]
                public int EventID get; set;

                [NotNull]
                public int ScoutDataID get; set;



                With this Table you can delete your public Event in the ScoutData-Table and call the Event-Table with the ScoutDataID. For Example :



                var sD = conn.Table<ScoutData>().FirstOrDefaultAsync().Result;
                var sDE = conn.Table<ScoutDataEvent>().Where(p => p.ScoutDataID == sD.ID).FirstOrDefaultAsync().Result;
                var event = conn.Table<Event>().Where(p => p.ID == sDE.EventID).FirstOrDefaultAsync().Result;





                share|improve this answer

























                  0












                  0








                  0







                  I would suggest to create a table ScoutDataEvent or so, to get a connection between the two tables.



                  public class ScoutDataEvent

                  [PrimaryKey]
                  public int ID get; set;

                  [NotNull]
                  public int EventID get; set;

                  [NotNull]
                  public int ScoutDataID get; set;



                  With this Table you can delete your public Event in the ScoutData-Table and call the Event-Table with the ScoutDataID. For Example :



                  var sD = conn.Table<ScoutData>().FirstOrDefaultAsync().Result;
                  var sDE = conn.Table<ScoutDataEvent>().Where(p => p.ScoutDataID == sD.ID).FirstOrDefaultAsync().Result;
                  var event = conn.Table<Event>().Where(p => p.ID == sDE.EventID).FirstOrDefaultAsync().Result;





                  share|improve this answer













                  I would suggest to create a table ScoutDataEvent or so, to get a connection between the two tables.



                  public class ScoutDataEvent

                  [PrimaryKey]
                  public int ID get; set;

                  [NotNull]
                  public int EventID get; set;

                  [NotNull]
                  public int ScoutDataID get; set;



                  With this Table you can delete your public Event in the ScoutData-Table and call the Event-Table with the ScoutDataID. For Example :



                  var sD = conn.Table<ScoutData>().FirstOrDefaultAsync().Result;
                  var sDE = conn.Table<ScoutDataEvent>().Where(p => p.ScoutDataID == sD.ID).FirstOrDefaultAsync().Result;
                  var event = conn.Table<Event>().Where(p => p.ID == sDE.EventID).FirstOrDefaultAsync().Result;






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 at 11:51









                  TosTTosT

                  32




                  32



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035258%2fsqlite-cannot-find-class-when-creating-table%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      1928 у кіно

                      Захаров Федір Захарович

                      Ель Греко