{"id":9030,"date":"2018-05-01T10:00:10","date_gmt":"2018-05-01T01:00:10","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=9030"},"modified":"2018-04-29T22:54:04","modified_gmt":"2018-04-29T13:54:04","slug":"ef%e3%81%ae%e3%82%af%e3%83%a9%e3%82%b9%e3%82%92mvvm%e3%81%aeinotifypropertychanged%e3%81%ab%e5%af%be%e5%bf%9c%e3%81%95%e3%81%9b%e3%82%8b%e8%a3%8f%e6%8a%80","status":"publish","type":"post","link":"https:\/\/www.moonmile.net\/blog\/archives\/9030","title":{"rendered":"EF\u306e\u30af\u30e9\u30b9\u3092MVVM\u306eINotifyPropertyChanged\u306b\u5bfe\u5fdc\u3055\u305b\u308b\u88cf\u6280"},"content":{"rendered":"<p>\nWPF\u3067EF(Entitiy Framework)\u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u3001\u30ea\u30b9\u30c8\u8868\u793a\u306b\u306f\u697d\u306a\u306e\u3060\u304c\u3001\u30c7\u30fc\u30bf\u3092\u53cd\u6620\u3059\u308b\u305f\u3081\u306b\u306fINotifyPropertyChanged\u3092\u7d99\u627f\u3055\u305b\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u304f\u3066\u3001\u305d\u3053\u304c\u9762\u5012\u304f\u3055\u3044\u3002\u3044\u3061\u3044\u3061\u3001ViewModel \u30af\u30e9\u30b9\u3067 EF \u306e\u30af\u30e9\u30b9\u3092\u304f\u308b\u3081\u3070\u826f\u3044\u306e\u3060\u304c\u3001\u305d\u308c\u3092\u81ea\u52d5\u5316\u3057\u305f\u3044\u3002<br \/>\n\u7279\u306b\u30de\u30b9\u30bf\u30fc\u7ba1\u7406\u7528\u306e\u753b\u9762\u306a\u3093\u304b\u3092\u4f5c\u308b\u3068\u304d\u306f\u3001ASP.NET MVC\u306e\u3088\u3046\u306b\u8db3\u5834\u3092\u81ea\u52d5\u5316\u3055\u305b\u3066\u304a\u304d\u305f\u3044\u3068\u3044\u3046\u306e\u3082\u3042\u308b\u3002\n<\/p>\n<p>\nEF\u3067\u51fa\u529b\u3055\u308c\u308b\u30af\u30e9\u30b9\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30af\u30e9\u30b9\u306a\u306e\u3067\u3001\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\npublic partial class \u793e\u54e1\u540d\n{\n    public int \u793e\u54e1\uff29\uff24 { get; set; }\n    public Nullable&lt;int&gt; \u90e8\u7f72ID { get; set; }\n    public Nullable&lt;int&gt; \u55b6\u696d\u62c5\u5f53FLG { get; set; }\n    public string \u793e\u54e1\u540d1 { get; set; }\n}\n<\/pre>\n<p>\nMVVM\u5bfe\u5fdc\u306eINotifyPropertyChanged\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u7d99\u627f\u3057\u305f\u3053\u3093\u306a\u30af\u30e9\u30b9\u306b\u3057\u305f\u3044\u308f\u3051\u3060\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\npublic partial class \u793e\u54e1\u540d : ObservableObject \n{\n    private int _\u793e\u54e1\uff29\uff24 ;\n    public int \u793e\u54e1\uff29\uff24 {\n    \tget { return _\u793e\u54e1\uff29\uff24; }\n    \tset { SetProperty( ref _\u793e\u54e1\uff29\uff24, value, nameof(\u793e\u54e1\uff29\uff24)); }\n    }\n    private Nullable&lt;int&gt; _\u90e8\u7f72ID ;\n    public Nullable&lt;int&gt; \u90e8\u7f72ID {\n    \tget { return _\u90e8\u7f72ID; }\n    \tset { SetProperty( ref _\u90e8\u7f72ID, value, nameof(\u90e8\u7f72ID)); }\n    }\n    private Nullable&lt;int&gt; _\u55b6\u696d\u62c5\u5f53FLG ;\n    public Nullable&lt;int&gt; \u55b6\u696d\u62c5\u5f53FLG {\n    \tget { return _\u55b6\u696d\u62c5\u5f53FLG; }\n    \tset { SetProperty( ref _\u55b6\u696d\u62c5\u5f53FLG, value, nameof(\u55b6\u696d\u62c5\u5f53FLG)); }\n    }\n    private string _\u793e\u54e1\u540d1 ;\n    public string \u793e\u54e1\u540d1 {\n    \tget { return _\u793e\u54e1\u540d1; }\n    \tset { SetProperty( ref _\u793e\u54e1\u540d1, value, nameof(\u793e\u54e1\u540d1)); }\n    }\n}\n<\/pre>\n<p>\n\u3053\u3046\u3057\u3066\u304a\u304f\u3068\u3001\u30ea\u30b9\u30c8\u30d3\u30e5\u30fc\u3067\u4e00\u89a7\u8868\u793a\u3092\u3055\u305b\u3066\u304a\u3044\u3066\u3001\u9078\u629e\u6642\u306b\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u3078\u8868\u793a\u3001\u305d\u3057\u3066\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u3067\u306e\u5909\u66f4\u304c\u30ea\u30b9\u30c8\u30d3\u30e5\u30fc\u306b\u53cd\u6620\u3055\u308c\u308b\u3001\u3068\u3044\u3046\u3068\u3053\u308d\u304c\u81ea\u52d5\u5316\u3055\u308c\u308b\u3002\n<\/p>\n<p><h2>Model1.tt\u3092\u76f4\u63a5\u66f8\u304d\u66ff\u3048\u308b<\/h2>\n<\/p>\n<p>\n\u5143\u306e\u30af\u30e9\u30b9\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u901a\u3057\u3066\u3001MVVM\u5bfe\u5fdc\u306e\u30af\u30e9\u30b9\u3092\u4f5c\u308d\u3046\u304b\u3068\u3082\u601d\u3063\u305f\u306e\u3060\u304c\u3001\u3082\u3063\u3068\u7c21\u5358\u306b EF \u3067\u51fa\u529b\u3055\u308c\u308b Model1.tt \u3092\u76f4\u63a5\u66f8\u304d\u66ff\u3048\u3066\u3057\u307e\u3046\u3002T4 \u3067\u66f8\u304b\u308c\u3066\u3044\u308b Model1.tt \u306f\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u305f\u9014\u7aef\u306b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u5f93\u3063\u3066\u5404\u30af\u30e9\u30b9\u304c\u51fa\u529b\u3055\u308c\u308b\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\npublic class CodeStringGenerator\n{\n\t...\n    public string Property(EdmProperty edmProperty)\n    {\n        return string.Format(\n            CultureInfo.InvariantCulture,\n\t\t\t\/\/ \u2605\u3053\u3053\u3092\u66f8\u304d\u66ff\u3048\n@&quot;private {1} _{2} ;\n\t{0} {1} {2} {{\n\t\tget {{ return _{2}; }}\n\t\tset {{ SetProperty( ref _{2}, value, nameof({2})); }}\n\t}}&quot;,\n\n\t\t\t\/\/ &quot;{0} {1} {2} {{ {3}get; {4}set; }}&quot;,\n            Accessibility.ForProperty(edmProperty),\n            _typeMapper.GetTypeName(edmProperty.TypeUsage),\n            _code.Escape(edmProperty),\n            _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),\n            _code.SpaceAfter(Accessibility.ForSetter(edmProperty)));\n    }\n\t...\n    public string EntityClassOpening(EntityType entity)\n    {\n        return string.Format(\n            CultureInfo.InvariantCulture,\n\t\t\t\/\/ \u2605\u3053\u3053\u3092\u66f8\u304d\u66ff\u3048\n            &quot;{0} {1}partial class {2}{3} : ObservableObject &quot;,\n            Accessibility.ForType(entity),\n            _code.SpaceAfter(_code.AbstractOption(entity)),\n            _code.Escape(entity),\n            _code.StringBefore(&quot; : &quot;, _typeMapper.GetTypeName(entity.BaseType)));\n    }\n\t...\n}\n<\/pre>\n<p>\n\u5927\u3056\u3063\u3071\u3060\u304c\u3001CodeStringGenerator\u30af\u30e9\u30b9\u306eProperty\u30e1\u30bd\u30c3\u30c9\u3068EntityClassOpening\u30e1\u30bd\u30c3\u30c9\u306e\u5185\u5bb9\u3092\u66f8\u304d\u66ff\u3048\u3066\u3057\u307e\u3046\u3002\n<\/p>\n<p>\nEntityClassOpening \u306f\u3001\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u306e\u30af\u30e9\u30b9\u3092\u51fa\u529b\u3059\u308b\u3068\u3053\u308d\u306a\u306e\u3067\u3001INotifyPropertyChanged\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3057\u305f\u300cObservableObject\u300d\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3059\u308b\u3088\u3046\u306b\u66f8\u304d\u66ff\u3048\u308b\u3002ObservableObject\u30af\u30e9\u30b9\u306f\u5225\u9014\u81ea\u524d\u3067\u7528\u610f\u3057\u3066\u304a\u304f\u3002<br \/>\nProperty \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u51fa\u529b\u3059\u308b\u3068\u3053\u308d\u306a\u306e\u3067\u3001SetProperty \u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u5909\u66f4\u901a\u77e5\u304c\u98db\u3076\u3088\u3046\u306b\u3059\u308b\u3002\n<\/p>\n<p>\n\u3053\u308c\u3092\u4fdd\u5b58\u3059\u308b\u3068\u3001\u5404\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u306e\u30af\u30e9\u30b9\u304c\u3001\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\npublic partial class \u793e\u54e1\u540d : ObservableObject \n{\n    private int _\u793e\u54e1\uff29\uff24 ;\n    public int \u793e\u54e1\uff29\uff24 {\n    \tget { return _\u793e\u54e1\uff29\uff24; }\n    \tset { SetProperty( ref _\u793e\u54e1\uff29\uff24, value, nameof(\u793e\u54e1\uff29\uff24)); }\n    }\n\t...\n}\n<\/pre>\n<p>\n\u306e\u3088\u3046\u306b\u66f8\u304d\u5909\u308f\u308b\u3002\n<\/p>\n<p><a href='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2018\/04\/dworkblogimage20180429_01org.jpg'><img border='0' src='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2018\/04\/dworkblogimage20180429_01thum.jpg'\/><\/a><\/p>\n<p>\n\u306e\u3088\u3046\u306a\u753b\u9762\u304c\u3001\u30d0\u30a4\u30f3\u30c9\u3060\u3051\u3067\u4f5c\u308c\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WPF\u3067EF(Entitiy Framework)\u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u3001\u30ea\u30b9\u30c8\u8868\u793a\u306b\u306f\u697d\u306a\u306e\u3060\u304c\u3001\u30c7\u30fc\u30bf\u3092\u53cd\u6620\u3059\u308b\u305f\u3081\u306b\u306fINotifyPropertyChanged\u3092\u7d99\u627f\u3055\u305b\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u304f\u3066\u3001\u305d\u3053\u304c\u9762\u5012\u304f\u3055\u3044\u3002\u3044\u3061\u3044\u3061\u3001V &hellip; <a href=\"https:\/\/www.moonmile.net\/blog\/archives\/9030\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,23],"tags":[],"class_list":["post-9030","post","type-post","status-publish","format-standard","hentry","category-dev","category-csharp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=9030"}],"version-history":[{"count":1,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9030\/revisions"}],"predecessor-version":[{"id":9031,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/9030\/revisions\/9031"}],"wp:attachment":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=9030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=9030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=9030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}