æ¢åï¼v3.5 æ代ï¼ã®ã¢ãã«ã«ãããã¢ã½ã·ã¨ã¼ã·ã§ã³ãå¤é¨ãã¼ã¢ã½ã·ã¨ã¼ã·ã§ã³ã¸å¤æ´ããæ¹æ³
Entity Framework v1ã§å¤é¨ãã¼ã«ãããªã¬ã¼ã·ã§ã³ã¯ãã¢ã½ã·ã¨ã¼ã·ã§ã³ã¨ãã¦ãããã³ã°ããã¦ãã¾ããã
ãããªãã¼ãã«ã§ãProducts.CategoryIdãCategories.Idãåç §ãã¦ããã¨ãã¾ããããã1.0ã§èªåçæããã¨ãã¢ã½ã·ã¨ã¼ã·ã§ã³ãä½ããããããªæãã«ãªãã¾ãï¼è¤æ°å½¢ãæã§åæ°å½¢ã«ç´ããï¼
ãã®ããããã ã¨ãProductã«ã¯ãCategoryIdã¨ãããã¼ãã®ãã®ã¯ãªããªãã代ããã«Categoryã®ã¤ã³ã¹ã¿ã³ã¹ãã®ãã®ãåç §ã§ããããã«ã¢ã½ã·ã¨ã¼ã·ã§ã³ãä½ããã¾ããããã¯ããã§ææ³ã¨ãã¦ã¯ãã£ãããã¦ãã¾ãããã ãå®éã«ã¢ããªã±ã¼ã·ã§ã³ãä½ã£ã¦ããã¨ãã©ããã¦ãCategoryIdèªä½ãåç §ããããªããã¨ãããã¾ãããããv1ã§ãããã¨ããã¨ãEntityKeyãã
(long)_product.CategoryReference.EntityKey.EntityKeyValues.First().Value;
ã¿ãããªãã¨ãããå¿ è¦ãããã¾ãããããã©ãã§ãã
ããã«å¯¾ãã¦ãEntity Framework ï½4ã§ã¯ãå¤é¨ãã¼ã§ããCategoryIdãæ®ããã¾ã¾ã¢ã½ã·ã¼ã¨ã·ã§ã³ãå¼µããããã«ãªãã¨ãããã¨ã§ããã
ãã£ãã4ã«ãªã£ã¦ãæ¢åã®ã³ã¼ãã移è¡ãããã¹ã試ãã¦ã¿ãã®ã§ãããæ¢åã®ã¢ã½ã·ã¨ã¼ã·ã§ã³ã«èªåçã«ã¹ã«ã©ããããã£ãå®ç¾©ãããã®ãã¨æããããã©ãããããã§ã¯ãªãããã§ãããããããå¤é¨ãã¼ãæ®ããã¾ã¾ã®ã¢ã½ã·ã¨ã¼ã·ã§ã³ã¨ãv1æµã®å¤é¨ãã¼ãæ®ããªãã¢ã½ã·ã¨ã¼ã·ã§ã³ã¨ã§ã¯ãããããæå³åããç°ãªããããªã®ã§ããåè ï¼v4ã§æ¡ç¨ããããå¤é¨ãã¼ãåç §ã§ããã¿ã¤ãã®ãã®ï¼ããå¤é¨ãã¼ã¢ã½ã·ã¨ã¼ã·ã§ã³ãã¨ãããå¾è ï¼v1ã§ä½¿ããã¦ããæ§æ¥ã®ãã®ï¼ããç¬ç«ã¢ã½ã·ã¨ã¼ã·ã§ã³ãã¨å¼ã¶ããã§ãï¼http://msdn.microsoft.com/ja-jp/library/ee373856.aspx ãåç §ï¼ã
ã¨ããããã§ãæ¢åã®EDMãã¡ã¤ã«ãããå ´åã¯ãåç´ã«éãç´ãã°å¤é¨ãã¼ã使ããã¨ãããã¨ã«ã¯ãªãã¾ãããã²ã¨ã¤ã²ã¨ã¤ã®ã¢ã½ã·ã¨ã¼ã·ã§ã³ã«å¯¾ãã¦æ¬¡ã®ãããªä½æ¥ãå¿ è¦ã«ãªãã¾ãã
- ã¹ã«ã©ããããã£CategoryIdã追å ããåãããã³ã°ãè¨å®ãã
- ããã²ã¼ã·ã§ã³ãããã³ã°ãããã¢ã½ã·ã¨ã¼ã·ã§ã³ã®é¸æãã§è©²å½ã®ã¢ã½ã·ã¨ã¼ã·ã§ã³ã®ç·ï¼Categoryï¼ãé¸æãã
- ãåç §ã«å¯¾ããå¶ç´ãã§ãããªã³ã·ãã«ãã¯ãã®ã¾ã¾ï¼Categoryï¼ããããªã³ã·ãã«ãã¼ããåç §å ã®ãã©ã¤ããªãã¼ï¼ä¾ã§ã¯Idï¼ããä¾åãã¼ããä¸ã§ä½æããå¤é¨ãã¼ï¼ä¾ã§ã¯CategoryIdï¼ã¨ãã¦ä½¿ãããããã£ã«è¨å®
- ã¢ã½ã·ã¨ã¼ã·ã§ã³ã®ç·ãé¸æããããããã³ã°ã®è©³ç´°ãã¿ããã¯ãªãã¯ãããããã³ã°ãåé¤ããããé¸æãã
ãããè¡ããã¨ã§ãç¡äºæ¢åã®ã³ã¼ãã移è¡ããããã¨ãåºæ¥ããã§ãããããç»é¢ã§ããã®ä»ã¡ãã£ã¨æéãªã®ã§ãXMLã ãã®åé¡ã ã£ãããã¹ã¯ãªããã§ä¸æ¬ç½®æããã°ããããªã¨æã£ããã§ãããã³ã¼ãããã¤ã³ãã«ããªã«ããæ°ããã³ã¼ããçæããã¦ãããããªã®ã§ãå¿ è¦ãªã¨ããã ãæã§ããããã¨ããæ°ã«ãªã£ã¦ãã¾ãã