I have a problem with DataContext - it inserts existing data in my database, even without calling InsertOnSubmit. Any ideas?

Here's the code:

ApplicationDataDataContext db = new ApplicationDataDataContext();
ChangeSet c = db.GetChangeSet(); // nothing to insert
Place place = new Place();
place.Country = CountryClass.CreateObject(countryXmlString, db);
c = db.GetChangeSet(); // one Place is waiting for insert
public static class CountryClass
    {

public static Country CreateObject(string xmlCountryString, ApplicationDataDataContext db)
        {
            Country country = new Country();
            country.LoadXml(xmlCountryString);
            return country.Save(db);
        }

public static void LoadXml(this Country root, string xmlCountryString)
        {
		// loads data from XML file

            XmlDocument xmlCountry = new XmlDocument();
           
            try
            {
                xmlCountry.LoadXml(xmlCountryString);
                XmlNode rootElement = xmlCountry.DocumentElement;

                root.countryNameISOcode = rootElement.InnerText;
            }
            catch (XmlException e)
            {
                ...
            }
        }


public static Country Save(this Country root, ApplicationDataDataContext db)
        {
            Country country = (from c in db.Countries
                                 where c.countryNameISOcode == root.countryNameISOcode
                                 select c).FirstOrDefault();

					// one country found
            return country;

        }
}

Please help, it's very important... :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.