Hello,
Our company is trying to set up a pretty basic WPF Program with a code-first database (FluentModel) and a RadGridView to edit/add/delete data.
So far, everything works, except for the deleting/adding data part. Editting works just fine.
It's a MSSQL Database that gets all of its mapping and fields from Telerik's FluentMetaDataSource .
The problem, I think, lies in the fact that getting data using OpenAccessContent.GetAll<>() returns an IQueryable.
When using this IQueryable, the button to add a new row ("Click here to add new item") simply doesn't work.
A workaround for this is returning an IList instead using OpenAccessContent.GetAll<Type>().ToList() .
Using this as an ItemsSource instead makes it possible to edit existing items (and they can get retreived using our FluentModel's GetChanges().GetUpdates<Type>() method. However, GetInserts<Type>() and GetDeletes<Type>() is always empty, even though we visually see the data in the RadGridView. The changes simply don't go through.
Am I missing a very simple step? I certainly hope so.
Summary: Data CAN be editted and gets passed to the context's (FluentModel) GetChanges().GetUpdates() list. Inserts/Deletes SEEM to work VISUALLY in the RadGridView, but rows do NOT actually get inserted/deleted and the GetInserts() and GetDeletes() lists are always EMPTY. What could be the cause of this?
Thank you for taking your time to read and help
Our company is trying to set up a pretty basic WPF Program with a code-first database (FluentModel) and a RadGridView to edit/add/delete data.
So far, everything works, except for the deleting/adding data part. Editting works just fine.
It's a MSSQL Database that gets all of its mapping and fields from Telerik's FluentMetaDataSource .
The problem, I think, lies in the fact that getting data using OpenAccessContent.GetAll<>() returns an IQueryable.
When using this IQueryable, the button to add a new row ("Click here to add new item") simply doesn't work.
A workaround for this is returning an IList instead using OpenAccessContent.GetAll<Type>().ToList() .
Using this as an ItemsSource instead makes it possible to edit existing items (and they can get retreived using our FluentModel's GetChanges().GetUpdates<Type>() method. However, GetInserts<Type>() and GetDeletes<Type>() is always empty, even though we visually see the data in the RadGridView. The changes simply don't go through.
Am I missing a very simple step? I certainly hope so.
01.<controls:RadGridView ItemsSource="{Binding Units}"02. x:Name="UnitGridView"03. CanUserFreezeColumns="False"04. NewRowPosition="Top"05. RowIndicatorVisibility="Collapsed"06. GroupRenderMode="Flat"07. ShowColumnFooters="False"08. ShowColumnHeaders="True"09. CanUserSortColumns="True"10. ShowColumnSortIndexes="True"11. ShowGroupFooters="False"12. ShowGroupPanel="False"13. GridLinesVisibility="Both"14. BorderBrush="Transparent"15. BorderThickness="0"16. RowStyle="{StaticResource RowStyle}"17. SelectedItem="{Binding SelectedUnit, Mode=TwoWay}"18. AutoGenerateColumns="False"19. SelectionUnit="FullRow">20. 21. <controls:RadGridView.Columns>22. <controls:GridViewDataColumn DataMemberBinding="{Binding Id}" IsReadOnly="True"/>23. <!-- Fields ... -->
24. </controls:RadGridView.Columns>25.</controls:RadGridView>01.public class FluentModel : OpenAccessContext, IFluentModelUnitOfWork02.{03. private static string connectionStringName = @"connectionId";04. public static String ConnectionString{get { return ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; }}05. 06. private static readonly BackendConfiguration backend = GetBackendConfiguration();07. private static readonly MetadataSource metadataSource = new FluentModelMetadataSource();08. 09. #region Lists10. 11. public IList<UnitType> UnitTypes12. {13. get { return GetAll<UnitType>().ToList(); }14. }15. 16. public IList<Address> Addresses17. {18. get { return GetAll<Address>().ToList(); }19. }20. 21. public IList<Project> Projects22. {23. get { return GetAll<Project>().ToList(); }24. }25. 26. public IList<Unit> Units27. {28. get { return GetAll<Unit>().ToList(); }29. }30. 31. #endregion32. 33. #region constructors34. public FluentModel()35. : base(connectionStringName, backend, metadataSource)36. { }37. 38. public FluentModel(string connection)39. : base(connection, backend, metadataSource)40. { }41. 42. public FluentModel(BackendConfiguration backendConfiguration)43. : base(connectionStringName, backendConfiguration, metadataSource)44. { }45. 46. public FluentModel(string connection, MetadataSource metadataSource)47. : base(connection, backend, metadataSource)48. { }49. 50. public FluentModel(string connection, BackendConfiguration backendConfiguration, MetadataSource metadataSource)51. : base(connection, backendConfiguration, metadataSource)52. { }53. #endregion54. 55. public static BackendConfiguration GetBackendConfiguration()56. {57. BackendConfiguration backend = new BackendConfiguration();58. backend.Backend = "MsSql";59. backend.ProviderName = "System.Data.SqlClient";60. return backend;61. }62.}Summary: Data CAN be editted and gets passed to the context's (FluentModel) GetChanges().GetUpdates() list. Inserts/Deletes SEEM to work VISUALLY in the RadGridView, but rows do NOT actually get inserted/deleted and the GetInserts() and GetDeletes() lists are always EMPTY. What could be the cause of this?
Thank you for taking your time to read and help