none
Reading data from sequal database into IDictionary RRS feed

  • Question

  • I am moving a program off an odd database over to MS Sequal. One of the routine involves reading from the database into IDictionary's. The old code looks like this.

    IDictionary<string, IdentificationNumber> ids = unit.Get<IdentificationNumbers>(IdentificationNumbers.Keyname).Entries.ToDictionary(id => id.Code);

    How to I rewrite this to use something like

    IDictionary<string, IdentificationNumberDB> ids = from n in db.IdentificationNumberDB select n;

    The model is

    public class IndentificationNumberDB

    {

        public static readonly IdentificationNumberDB unknown = new IdentificationNumberDB() { Code = string.empty, Name = string.empty };

        public string Code {get; set; }

        public string Name { get; set; }

    }

    Thursday, October 18, 2012 1:41 PM

Answers

  • Hi John,

    First, could you please clarify the MS Sequal you mentioned?   I have no idea what product it is. 

    Besides, it seems that you want to make some DB query into LINQ query?   Maybe you can first declare some db context class to inherit the unit class

    class MyContext : Unit
    {
        public IEnumerable<IdentificationNumbers> IdentificationNumberDB
        {
            get
            {
                  return base.Get<IdentificationNumbers>("Keyname").Entries;
            }
        }
    }

    Good day!

    Thanks


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, October 23, 2012 5:44 AM