Q:

WPF Data Binding and Data from SQL DataTable - need some ideas

i have a lot of some WPF windows. On them i write some code, which binds UI controls and data, something like this:
    public class AddressWindow
    {
        public string AddressID { get; set; }
        public string Addr1 { get; set; }
        public string Addr2 { get; set; }
        public string ZIP { get; set; }
        public string City { get; set; }
        public string Mobile { get; set; }
        public string FAX { get; set; }
        public string Country { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public bool IsSystem { get; set; }
        public bool Enabled { get; set; }

    }

       private void BindInCode()
        {
            var address = new AddressWindow
            {
//                AddressID = "110",
//                Addr1 = "Kaunas",
//                Addr2 = "Jonavos",
//                ZIP = "8987",
//                City = "miestas",
//                Mobile = "869985868",
//                FAX = "87998",
//                Country = "Lithuania",
//                Email = "emailas@ree.lt",
//                Phone = "37598288",
//                IsSystem = true,
//                Enabled = false
            };

            Binding binding = new Binding();

            binding.Source = address;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            binding.Path = new PropertyPath("AddressID");
            this.db_AddressID.SetBinding(TextEdit.TextProperty, binding);

            binding = new Binding();
            binding.Source = address;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            binding.Path = new PropertyPath("Addr1");
            this.db_Addr1.SetBinding(TextEdit.TextProperty, binding);

           ...............
}

Now  I want to create some universal simple engine, to fill Data values(assign values from DataTable to my class properties). Does anyone knows some way how to do that..? In example is there some way to assign values by names of properties. Lets say my property names equals to names of Columns from dataRow. Is its possible in wpf to do something like that, or not, should i assign values in every window manually?

A:

Personally I've recourse to code generation to do the job, but you can use to Jimmy Bogard's AutoMapper, which does pretty much what you're talking about. It is on CodePlex and GoogleCode.

