Let's getting started

by Alexey Shirshov December 23, 2008 11:06

Consider the following table "Store"

taked from standard AdventureWorks database. How can we map the table with a minimum cost to access the data from code.

Well first of all you should add reference to Worm.Orm.dll and CoreFramework.dll assemblies. The next thing - create Store class.

    public class Store
    {
        public int CustomerID { get; set; }
        public string Name { get; set; }
    }

As you can see it just has two properties CustomerID and Name.

Third thing you should do is to add connection string to you database. For instance

Server=.\sqlexpress;Initial Catalog=AdventureWorks;Integrated security=true;

And the final step - writing a program. 

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

            foreach (Store s in query
                .From(new SourceFragment("Sales", "Store"))
                .ToPODList())
            {
                Console.WriteLine("Store id: {0}, name: {1}", s.CustomerID, 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.