We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

System.NotSupportedException: 'Don't know about System.TimeZoneInfo' When Creating Appointment Database Table

I'm trying to store appointments in a sqlite3 database.  When creating the appointments table i get the following error:

System.NotSupportedException: 'Don't know about System.TimeZoneInfo'

Here is the full trace:

   at SQLite.Orm.SqlType(Column p, Boolean storeDateTimeAsTicks, Boolean storeTimeSpanAsTicks)

   at SQLite.Orm.SqlDecl(Column p, Boolean storeDateTimeAsTicks, Boolean storeTimeSpanAsTicks)

   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()

   at SQLite.SQLiteConnection.CreateTable(Type ty, CreateFlags createFlags)

   at Ranch_Manager.Logic.Repository.<CreateScheduleTable>b__23_0() in C:\Users\chris\source\repos\Ranch-Manager\Logic\Repository.cs:line 440

   at System.Threading.Tasks.Task`1.InnerInvoke()

   at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)

   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)


Any assistance would be greatly appreciated.


4 Replies

SS SaiGanesh Sakthivel Syncfusion Team October 10, 2022 01:13 PM UTC

Hi Joshua,


We are currently preparing a simple sample with a Sqlite3 database and comparing it to the reported scenario. We will update you with further details on October 12, 2022. In the meantime, could you please share the issue replication sample from your side, which could help us provide a better solution as soon as possible?


Regards,
SaiGanesh Sakthivel



JO Joshua October 10, 2022 02:26 PM UTC

Here is the model: 

public partial class Meeting : SchedulerAppointment

    {

        [PrimaryKey, AutoIncrement, Unique]

        public int ID { get; set; }

        public DateTime From { get; set; }

        public DateTime To { get; set; }

        public bool AllDay { get; set; }

        public string EventName { get; set; }

    }


The VM Implementation: 

 public async void SaveAppointment(SchedulerAppointment appointment)

        {

            bool success = await _db.AddNewCalendarEntry(appointment);

            if(success == true)

            {

                await Shell.Current.DisplayAlert("Appointment Added", "Your Appointment has been added to the calendar", "OK");

            }

            else

            {

                await Shell.Current.DisplayAlert("Error", "Your Appointment Was Unable to be Added to the Calendar", "OK");

            }

        }

And the DB Entry:

public async Task<bool> AddNewCalendarEntry(SchedulerAppointment entry)

        {

            bool success = false;

            string query = $"SELECT name FROM sqlite_master WHERE type='table' AND name='Calendar'";

            var exists = _database.ExecuteScalar<bool>(query);

            if(exists == true)

            {

                //New Entry add to the database

                if (entry.Id == null)

                {

                    var added = await Task.Run(() => _database.Insert(entry));

                    if (added > 0)

                    {

                        success = true;

                    }

                    else

                    {

                        success = false;

                    }

                }

                else

                {

                    //Updated Entry Update the existing record

                    var updated = await Task.Run(() => _database.Update(entry));

                    if (updated > 0)

                    {

                        success = true;

                    }

                }

            }

            else

            {

                await CreateScheduleTable();

                //New Entry add to the database

                if (entry.Id == null)

                {

                    var added = await Task.Run(() => _database.Insert(entry));

                    if (added > 0)

                    {

                        success = true;

                    }

                    else

                    {

                        success = false;

                    }

                }

                else

                {

                    //Updated Entry Update the existing record

                    var updated = await Task.Run(() => _database.Update(entry));

                    if (updated > 0)

                    {

                        success = true;

                    }

                }

            }


            return success;

        }



SS SaiGanesh Sakthivel Syncfusion Team October 11, 2022 12:23 PM UTC

Hi Joshua,


Thank you for the update. As we mentioned in the previous update. We will update you on further details on October 12, 2022. We appreciate the patience until then.


Regards,

SaiGanesh Sakthivel



SS SaiGanesh Sakthivel Syncfusion Team October 12, 2022 08:26 AM UTC

Hi Joshua,


#Regarding System.NotSupportedException: 'Don't know about System.TimeZoneInfo'

The reported scenario occurs due to the TimeZoneInfo property type will not be supported in sqlite database. In your shared sample Meeting class inherited from SchedulerAppointment and respective TimeZoneInfo type throws exception as restriction with sqllite, we are suggesting to you create the required custom class to create the Sqlite database table and bind the custom properties to the scheduler appointment mapping.


Custom model Class

public class Meeting

{

    [PrimaryKey, AutoIncrement, Unique]

    public int ID { get; set; }

    public DateTime From { get; set; }

    public DateTime To { get; set; }

    public bool AllDay { get; set; }

    public string EventName { get; set; }

}


In the Viewmodel class, create the observation collection for the custom class to add the appointments.

public ObservableCollection<Meeting> Events { get; set; }


In the view, bind the events to the AppointmentsSource property of the Scheduler and map the custom class properties to the SchedulerAppointment Mapping class.

<scheduler:SfScheduler x:Name="schedule" View="Month" AppointmentsSource="{Binding Events}"  AllowedViews="Day,Month,WorkWeek,TimelineDay,TimelineMonth,TimelineWeek,TimelineWorkWeek,Week,Agenda" >

    <scheduler:SfScheduler.AppointmentMapping>

        <scheduler:SchedulerAppointmentMapping StartTime="From" EndTime="To" Subject="EventName" IsAllDay="AllDay" Id="ID" />

    </scheduler:SfScheduler.AppointmentMapping>

    <scheduler:SfScheduler.BindingContext>

        <local:SchedulerViewModel/>

    </scheduler:SfScheduler.BindingContext>

</scheduler:SfScheduler>


Please refer to the following UG documentation for your reference.

UG: https://help.syncfusion.com/maui/scheduler/appointments#creating-business-objects


Please let us know if you have any concerns.


Regards,
SaiGanesh Sakthivel


Loader.
Live Chat Icon For mobile
Up arrow icon