Override Default Constructor of Partial Class with Another Partial Class

前端 未结 12 1845
时光取名叫无心
时光取名叫无心 2020-12-28 12:59

I don\'t think this is possible, but if is then I need it :)

I have a auto-generated proxy file from the wsdl.exe command line tool by Visual Studio 2008.

Th

12条回答
  •  一整个雨季
    2020-12-28 13:35

    I'm not quite addressing the OP, but if you happen to be generating classes with the EntityFramework Reverse POCO Generator, there's a partial method called in the constructor which is handy for initializing things you're adding via partial classes on your own...

    Generated by tool:

       [System.CodeDom.Compiler.GeneratedCode("EF.Reverse.POCO.Generator", "2.37.3.0")]
        public partial class Library {
            public string City { get; set; }
            public Library() {
                InitializePartial();
            }
            partial void InitializePartial();
        }
    

    added by you:

        public partial class Library {
            List Books { get; set; }
            partial void InitializePartial() {
                Books = new List();
            }
        }
    
        public class Book {
            public string Title { get; set; }
        }
    

提交回复
热议问题