This question is locked. New answers and comments are not allowed.
I have got two DAL connection, one to an mssql database, the other to an compact 4.0 database. Both databases are created using the same EntityDiagram.
Next I want to sync the new data from the mssql database, into the compact.
I tried using an approach like 'compactconnection.Add(mssqlconnection.DALCities.ToList())' but I kept getting an 'instances failed to persist' exception.
Code to get the DALCities list:
"return connection.DALCities.ToList();"
When I use another approach like:
- select all DALCity records from mssql database into list1
- loop list1, create new DALCity object, manually set values of .Name and .CountryId, add to list2
- add list2 to compact database
New code to get the new list:
"return connection.DALCities.Select(item => new DALCity { CityId = item.CityId, CityName = item.CityName}).ToList();"
That works fine, so my guess is that some of the metadata in the DALCity that I have selected from the mssql database keeps telling the compact database that this is an illegal object.
So my question is if there is an easier, more automagical way to 'clean' the objects by removing all metadata, so that the compact database will receive the object. That would save me a lot of coding (there are many tables), and reduces the chance of forgetting a field of two.
hope this made some kind of sense :)
Thanks in advance
-Thomas
Next I want to sync the new data from the mssql database, into the compact.
I tried using an approach like 'compactconnection.Add(mssqlconnection.DALCities.ToList())' but I kept getting an 'instances failed to persist' exception.
Code to get the DALCities list:
"return connection.DALCities.ToList();"
When I use another approach like:
- select all DALCity records from mssql database into list1
- loop list1, create new DALCity object, manually set values of .Name and .CountryId, add to list2
- add list2 to compact database
New code to get the new list:
"return connection.DALCities.Select(item => new DALCity { CityId = item.CityId, CityName = item.CityName}).ToList();"
That works fine, so my guess is that some of the metadata in the DALCity that I have selected from the mssql database keeps telling the compact database that this is an illegal object.
So my question is if there is an easier, more automagical way to 'clean' the objects by removing all metadata, so that the compact database will receive the object. That would save me a lot of coding (there are many tables), and reduces the chance of forgetting a field of two.
hope this made some kind of sense :)
Thanks in advance
-Thomas