Very simple question so I hope this doesn't get me shot to pieces on Stack.
I am trying to get to grips with the cool SharpRepository package however I have been unsuccessful in finding any useful information on how to impelement the XmlRepository assembly that is bundled with it.
Actually I speak a lie, the nuget version doesn't have it, the github version does but my crap attempts at trying to use it failed.
I compiled the github source then added a reference to SharpRepository.Repository and SharpRepository.XmlRepository, so far so good.
I then did a very simple test by first created a basic entity (name, address, postcode) and then did a quick test as follows:
var repo = new XmlRepository<Client, string>("C:\client.xml");
When I debug the console app and step into the source code on that line, drill down to the base class XmlRepositoryBase.cs and step through the method LoadItems() I get the an error when I try to execute the line
_items = (List<T>)serializer.Deserialize(reader);
I get the following error message:
<client xmlns=''> was not expected.
The class is very simple for the sake of testing:
public class Client
{
public Int32 Id { get; set; }
public String Name { get; set; }
public String Postcode { get; set; }
}
The XML file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<client>
<clientProfile>
<id>1</id>
<name>TheFragranceShop</name>
<description>The Fragrance Shop</description>
<enabled>true</enabled>
</clientProfile>
</client>
Thanks in advance and if I manage to work it out will post an update.
I received an answer from the authors:
This makes sense so I am going to use some of the answers already posted on Stack regarding this subject such as:
Creating an Entity from XML
I think the best solution will be to use a combination of Linq to XML and XML Serli