locked
Large amount of Data to use in C# code. RRS feed

  • Question

  • User-1852975005 posted

    Hi,

    Sorry if I have placed this in the wrong location.

    I need to make data available, say 95000 entries (may be more in future) available to C#.

    It will consist ot two parts.

    1. The original name of an item
    2. A new corresponding name for for each item

    ( There will be 90000 items approx)

    Also, access to each item should be as quick as posiible, as 3000 items have to be written to this way in less that 1 sec or as quick as possible.

    The code gets the original name and the new name has to be picked up for use.

    Any ideas please.

    Thanks,

    Friday, February 28, 2020 9:46 AM

Answers

  • User303363814 posted

    The easiest thing to do is to store them in a Dictionary.  Key is old name, Value is new name.  It would need a programmer to update the data.

    If you are worried about the size of the executable or updateability then you could read the entries from a file into the Dictionary at program startup.  The file would probably be in the tens of megabytes, so no big deal.  The data could be updated with Notepad and the program restarted, pretty easy

    If you need to have a separate program to add/modify/delete entries by multiple people then a database table would be a good solution.  If you don't have a database available you could use the external file approach but be careful about two user potentially updating the file at the same time.

    This is the ASP.Net forum so I assume that this is all happening on a web server.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 28, 2020 10:18 AM

All replies

  • User303363814 posted

    The easiest thing to do is to store them in a Dictionary.  Key is old name, Value is new name.  It would need a programmer to update the data.

    If you are worried about the size of the executable or updateability then you could read the entries from a file into the Dictionary at program startup.  The file would probably be in the tens of megabytes, so no big deal.  The data could be updated with Notepad and the program restarted, pretty easy

    If you need to have a separate program to add/modify/delete entries by multiple people then a database table would be a good solution.  If you don't have a database available you could use the external file approach but be careful about two user potentially updating the file at the same time.

    This is the ASP.Net forum so I assume that this is all happening on a web server.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 28, 2020 10:18 AM
  • User-1852975005 posted

    Thanks.

    How robust is the dictionary, can it be written to a file?

    The data only needs to be available to C# really.

    Example below works, but is slow. Is that because it is a console app?

    using System;
    using System.Collections.Generic;

    namespace ConsoleApp1
    {
    class Program
    {
    static void Main(string[] args)
    {
    IDictionary<string, string> dict = new Dictionary<string, string>();

    dict.Add(new KeyValuePair<string, string>("Test1", "One"));
    dict.Add(new KeyValuePair<string, string>("Test2", "Two"));

    //The following is also valid
    dict.Add("Test3", "Three");


    Console.WriteLine(dict["Test3"]);
    Console.ReadKey();

    }
    }
    }

    Thanks,

    Friday, February 28, 2020 10:28 AM
  • User753101303 posted

    Hi,

    Slow ? To compile and run maybe but certainly not to run ?

    A higher level view could help. You get this information from where ? ! Why do you even have to replace an old name with a new name rather than maybe using a unique id that never change ?

    Friday, February 28, 2020 12:05 PM
  • User-1852975005 posted

    Slow ? To compile and run maybe but certainly not to run ?
    Good to hear.

    Why do you even have to replace an old name with a new name rather than maybe using a unique id that never change ?
    A valid point. Afraid that is what I have been left to work with. Its to do with merging of an old system to a new one and variables having to use a different naming convention in the newer system.

    Thanks,

    Friday, February 28, 2020 3:14 PM
  • User475983607 posted

    Slow ? To compile and run maybe but certainly not to run ?
    Good to hear.

    Why do you even have to replace an old name with a new name rather than maybe using a unique id that never change ?
    A valid point. Afraid that is what I have been left to work with. Its to do with merging of an old system to a new one and variables having to use a different naming convention in the newer system.

    Thanks,

    The problem you are trying to solve is not clear.  Can you explain how changing variable names affect performance?  Is it possible to share code that illustrates the problem you are trying to solve?

    Friday, February 28, 2020 3:47 PM