Continue AdventureWorks mapping

by Alexey Shirshov April 07, 2009 16:01

In the previous post we have seen how simple we can map database table to class. Let's extend the mapping.

Suppose we don't want to use CustomerID. Instead, we want ID property. Also we want to add ModifiedDate column. Here is the code

    public class Store2
    {
        [EntityProperty("CustomerID")]
        public int ID { get; set; }
        public string Name { get; set; }
        public DateTime ModifiedDate { get; set; }
    }

The program might look like previous version with Store class.

        static void Main(string[] args)
        {
            var query = new QueryCmd(exam1sharp.Properties.Settings.Default.connString);

            foreach (Store2 s in query
                .From(new SourceFragment("Sales", "Store"))
                .ToPODList())
            {
                Console.WriteLine("Store id: {0}, name: {1}", s.ID, s.Name);
            }
        }

Tags:

Quickstart

Add comment


(Will show your Gravatar icon)  

Enter the word
captcha word
(hear it spoken)


  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen | Modified by Mooglegiant

The Author

My name is Alexey Shirshov. I'm a professional developer with wide specialization. I prefer VB.NET to C#, I hate ASP.NET but there is no better than it. You can contact me by this page.