Hi,
I want to bind UltraCalendarInfo used by WinSchedule with EF.
Is that possible ? Can anyone help me, when possible, with an example ?
Thnx
Hello Ton,
Thank you for posting to Infragistics Community!
I noticed that a similar question is discussed in this other forum thread. Please, note that according to our Support Policy we handle a single thread per question. This is for better consistency and to ensure that all your queries are addressed correctly. Thank you for understanding.
To address your specific question, I understand that you would like to bind the appointments in an UltraCalendarInfo control to objects representing them and contained within an EF Core DbSet, is that correct? What I can suggest is using the Local view of the DbSet, which as per its API in the Microsoft docs, can be used for data binding by populating the set with data and then binding to the local data through this property by calling ToBindingList() for WinForms:
this.ultraCalendarInfo1.DataBindingsForAppointments.DataSource = this.dbContext.Appointments.Local.ToBindingList(); this.ultraCalendarInfo1.DataBindingsForAppointments.StartDateTimeMember = "StartTime"; this.ultraCalendarInfo1.DataBindingsForAppointments.EndDateTimeMember = "EndTime"; this.ultraCalendarInfo1.DataBindingsForAppointments.SubjectMember = "Name";
For your convenience, I created a small sample demonstrating the idea with EF Core 6. It contains a DBContext class that overrides the OnModelCreating method to populate with example data. You can find the solution attached below. Please, note that you might have to restore/reinstall the EF Core and WinSchedule NuGet packages when running it on your side.
In conclusion, please, check out the referenced resources and let me know if they help. Also, please, keep in mind that working with EF Core as a framework is out of the scope of Infragistics Developer Support, as it is not directly related to Infragistics controls.
Best regards, Bozhidara Pachilova Associate Software Developer
3542.WinScheduleEFCore.zip
thnx Bozhidara
I was noit aware thaty it is out of scope. The more thanx for the reply.Have just a litte question more.
For the owner binding its the same recipe ?And change are saved by savechanges()?
Hi Ton,
Thank you for following up!
Sure, I believe the approach would be the same for the OwnersDataBinding, so feel free to test it as well. Regarding persisting the changes, I tested this as well by calling this.dbContext.SaveChanges(); in the AppointmentResized event as an example. When restarting the app the changes of the Start/End times made by resizing were correctly saved. So, yes, the changes could be persisted on certain events, or whenever needed and you as the developer is in control of that. Please, check on the WinSchedule API for an exhaustive list of the exposed events and properties.
Best regards,
Bozhidara Pachilova
Hi Bozhidara
Finally i got it almost working.
I made a did'nt gave the appointmenttable a key :-(
Now i put the savechanges() into the ultraCalenderInfo_afterappoinmentadded event
Due to some unkown reason not all the added appointments are saved in the database.
is there a possibility to add it somewhere in the routine when the save& close button is clicked on the appointdialog?
can you advise?
Good to hear you are having progress with the implementation.
I believe the confusion here stems from the fact that the dialog only adds a single appointment at a time. The AfterAppointmentAdded Event will fire either: 1. The first time you click File -> Save in the dialog or altrernatively on 2. Directly licking the Save & Close button.
I am under the impression that you assume that editing the information after clicking File->Save in the dialog initiates a new Appointment adding. However, this is not the case and the dialog is only editing the already added appointment.
Anyways, there is the AfterCloseAppointmentDialog Event, which you can use for that purpose. Also here is a complete list of the exposed by the UltraCalendarInfo class events. I hope this information helps.