J
J
jonillien2016-01-05 06:58:47
SQL
jonillien, 2016-01-05 06:58:47

XDocument.Load(path) (xml linq) - optimization, where is the best place in the project to create this object?

I apologize for the possible incorrectness, I do not understand linq well.
What is the best way to use XDocument (xml linq) assuming the db file gets big?
Make it common in the class and use it later in methods?

public class XmlController
    {
        private string dbPath = @"DB.xml";
        XDocument xDoc;

        public bool load()
        {           
            try
            {
                xDoc = XDocument.Load(dbPath);
        }
...........

Or create an object in each function, if necessary, make corrections in the xml code like this:
public bool addPack(string name)
        {
            try
            {
                XDocument xDoc = XDocument.Load(dbPath);
........

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vincent1, 2016-01-05
@Vincent1

... if we assume that the database file will become large?

Big is how much do you think?
How often are changes expected to be made?

J
jonillien, 2016-01-05
@jonillien

Big is how much do you think?

relatively, at least 50 - 100 thousand or more elements, with strings (words, sentences), dates, numbers.
Foreign memory program. words. Learning\repetitions - adding extras. data. Adding new decks and cards, etc. Data changes. Those. there is no continuous use of the xml file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question