{"id":3660,"date":"2023-11-28T18:06:40","date_gmt":"2023-11-28T10:06:40","guid":{"rendered":"http:\/\/www.ponybai.com\/?p=3660"},"modified":"2023-11-21T18:19:54","modified_gmt":"2023-11-21T10:19:54","slug":"sobject-%e9%9b%86%e5%90%88","status":"publish","type":"post","link":"http:\/\/www.ponybai.com\/?p=3660","title":{"rendered":"sObject \u96c6\u5408"},"content":{"rendered":"\n<p>\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>sObjects \u5217\u8868<\/strong>\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects<br>\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002<\/li>\n\n\n\n<li>\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0<strong>sObject<\/strong><br>\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002<samp>List.sort<\/samp><\/li>\n\n\n\n<li><strong>\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f<\/strong><\/li>\n\n\n\n<li><strong>\u5bf9\u8c61<\/strong><br>\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002<\/li>\n\n\n\n<li><strong>sObject<\/strong>\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject<br>\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">sObject \u5217\u8868<\/h2>\n\n\n\n<p>\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects\u3002 sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u6765\u5b58\u50a8 sObjects\u3002\u5217\u8868\u5728\u5de5\u4f5c\u65f6\u5f88\u6709\u7528 \u4f7f\u7528 SOQL \u67e5\u8be2\u3002SOQL \u67e5\u8be2\u8fd4\u56de sObject \u6570\u636e\u548c\u6b64\u6570\u636e \u53ef\u4ee5\u5b58\u50a8\u5728 sObject \u5217\u8868\u4e2d\u3002\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u6765\u6267\u884c \u6279\u91cf\u64cd\u4f5c\uff0c\u4f8b\u5982\u901a\u8fc7\u4e00\u6b21\u8c03\u7528\u63d2\u5165 sObject \u5217\u8868\u3002<\/p>\n\n\n\n<p>\u82e5\u8981\u58f0\u660e sObject \u5217\u8868\uff0c\u8bf7\u4f7f\u7528\u5173\u952e\u5b57\u540e\u8ddf sObject \u952e\u5165 &lt;&gt; \u4e2a\u5b57\u7b26\u4ee5\u5185\u3002\u4f8b\u5982\uff1a<samp>List<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create an empty list of Accounts\nList&lt;Account&gt; myList = new List&lt;Account&gt;();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ece SOQL \u67e5\u8be2\u81ea\u52a8\u586b\u5145\u5217\u8868<\/h2>\n\n\n\n<p>\u60a8\u53ef\u4ee5\u5c06 List \u53d8\u91cf\u76f4\u63a5\u5206\u914d\u7ed9 SOQL \u67e5\u8be2\u7684\u7ed3\u679c\u3002SOQL \u67e5\u8be2\u8fd4\u56de\u4e00\u4e2a \u4f7f\u7528\u8fd4\u56de\u7684\u8bb0\u5f55\u586b\u5145\u7684\u65b0\u5217\u8868\u3002\u786e\u4fdd\u58f0\u660e\u7684 List \u53d8\u91cf \u5305\u542b\u6b63\u5728\u67e5\u8be2\u7684\u76f8\u540c sObject\u3002\u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u901a\u7528\u7684 sObject \u6570\u636e \u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u58f0\u660e\u548c\u5206\u914d\u5e10\u6237\u5217\u8868 \u66f4\u6539\u4e3a SOQL \u67e5\u8be2\u7684\u8fd4\u56de\u503c\u3002\u67e5\u8be2\u6700\u591a\u8fd4\u56de 1,000 \u4e2a \u8fd4\u56de\u5305\u542b Id \u548c Name \u5b57\u6bb5\u7684\u5e10\u6237\u8bb0\u5f55\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create a list of account records from a SOQL query\nList&lt;Account&gt; accts = &#91;SELECT Id, Name FROM Account LIMIT 1000];<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6dfb\u52a0\u548c\u68c0\u7d22\u5217\u8868\u5143\u7d20<\/h2>\n\n\n\n<p>\u4e0e\u539f\u59cb\u6570\u636e\u7c7b\u578b\u5217\u8868\u4e00\u6837\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Apex \u63d0\u4f9b\u7684\u65b9\u6cd5\u8bbf\u95ee\u548c\u8bbe\u7f6e sObject \u5217\u8868\u7684\u5143\u7d20\u3002\u4f8b\u5982\uff1a<samp>List<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>List&lt;Account&gt; myList = new List&lt;Account&gt;(); \/\/ Define a new list\nAccount a = new Account(Name='Acme'); \/\/ Create the account first\nmyList.add(a);                    \/\/ Add the account sObject\nAccount a2 = myList.get(0);      \/\/ Retrieve the element at index 0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6279\u91cf\u5904\u7406<\/h2>\n\n\n\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u5c06\u5217\u8868\u4f20\u9012\u7ed9 DML \u64cd\u4f5c\u6765\u6279\u91cf\u5904\u7406 sObject \u5217\u8868\u3002\u8fd9 \u793a\u4f8b\u6f14\u793a\u5982\u4f55\u63d2\u5165 \u5e10\u6237\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Define the list\nList&lt;Account&gt; acctList = new List&lt;Account&gt;(); \n\/\/ Create account sObjects\nAccount a1 = new Account(Name='Account1'); \nAccount a2 = new Account(Name='Account2'); \n\/\/ Add accounts to the list\nacctList.add(a1);\nacctList.add(a2);\n\/\/ Bulk insert the list\ninsert acctList;<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u5982\u679c\u6279\u91cf\u63d2\u5165\u77e5\u8bc6\u6587\u7ae0\u7248\u672c\uff0c\u8bf7\u5c06\u6240\u6709 \u8bb0\u5f55\u76f8\u540c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bb0\u5f55 ID \u751f\u6210<\/h2>\n\n\n\n<p>Apex \u4f1a\u81ea\u52a8\u4e3a\u63d2\u5165\u6216\u66f4\u65b0\u63d2\u5165\u7684 sObject \u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5bf9\u8c61\u751f\u6210 ID \u4f7f\u7528 DML\u3002\u56e0\u6b64\uff0c\u5305\u542b\u591a\u4e2a sObject \u5b9e\u4f8b\u7684\u5217\u8868\u4e0d\u80fd \u5373\u4f7f\u5b83\u6709 ID\uff0c\u4e5f\u4f1a\u63d2\u5165\u6216\u66f4\u65b0\u63d2\u5165\u3002\u8fd9\u79cd\u60c5\u51b5\u610f\u5473\u7740\u9700\u8981\u5c06\u4e24\u4e2a ID \u5199\u5165\u76f8\u540c\u7684 ID \u5185\u5b58\u4e2d\u7684\u7ed3\u6784\uff0c\u8fd9\u662f\u975e\u6cd5\u7684\u3002<samp>null<\/samp><\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u4ee5\u4e0b\u4ee3\u7801\u5757\u4e2d\u7684\u8bed\u53e5\u751f\u6210 a \u56e0\u4e3a\u5b83 \u5c1d\u8bd5\u63d2\u5165\u4e00\u4e2a\u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u5bf9\u540c\u4e00 sObject \uff08\uff09 \u7684\u4e24\u4e2a\u5f15\u7528\uff1a<samp>insert<\/samp><samp>ListException<\/samp><samp>a<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try {\n\n   \/\/ Create a list with two references to the same sObject element\n   Account a = new Account();\n   List&lt;Account&gt; accs = new List&lt;Account&gt;{a, a};\n\n   \/\/ Attempt to insert it...\n   insert accs;\n\n   \/\/ Will not get here\n   System.assert(false);\n} catch (ListException e) {\n   \/\/ But will get here\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5bf9 s\u5bf9\u8c61<\/h2>\n\n\n\n<p>\u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u8868\u793a\u6cd5\uff08\u6b63\u65b9\u5f62 \u62ec\u53f7\uff09\u6765\u58f0\u660e\u548c\u5f15\u7528 sObject \u7684\u5217\u8868\u3002\u6b64\u793a\u4f8b\u4f7f\u7528\u6570\u7ec4\u58f0\u660e\u5e10\u6237\u5217\u8868 \u8868\u793a\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Account&#91;] accts = new Account&#91;1];<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u793a\u4f8b\u4f7f\u7528\u65b9\u62ec\u53f7\u5411\u5217\u8868\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5143\u7d20\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>accts&#91;0] = new Account(Name='Acme2');<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e9b\u793a\u4f8b\u8fd8\u5c06\u6570\u7ec4\u8868\u793a\u6cd5\u7528\u4e8e sObject \u5217\u8868\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u4f8b<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td><code>List&lt;Account&gt; accts = new Account[]{};<\/code><\/td><td>\u5b9a\u4e49\u4e0d\u5e26\u5143\u7d20\u7684\u5e10\u6237\u5217\u8868\u3002<\/td><\/tr><tr><td><code>List&lt;Account&gt; accts = new Account[] {new Account(), null, new Account()};<\/code><\/td><td>\u5b9a\u4e49\u4e00\u4e2a Account \u5217\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e3a\u4e09\u4e2a Account \u5206\u914d\u7684\u5185\u5b58\uff1a\u4e00\u4e2a\u65b0\u7684 Account \u5bf9\u8c61 \u7b2c\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u5728\u7b2c\u4e8c\u4e2a\u4f4d\u7f6e\uff0c \u4ee5\u53ca\u7b2c\u4e09\u4e2a\u4e2d\u7684\u53e6\u4e00\u4e2a\u65b0 Account \u5bf9\u8c61\u3002<samp>null<\/samp><\/td><\/tr><tr><td><code>List&lt;Contact&gt; contacts = new List&lt;Contact&gt; (otherList);<\/code><\/td><td>\u4f7f\u7528\u65b0\u5217\u8868\u5b9a\u4e49\u8054\u7cfb\u4eba\u5217\u8868\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f<\/h2>\n\n\n\n<p>\u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u6392\u5e8f sObject \u7684\u5217\u8868\u3002<\/p>\n\n\n\n<p><samp>List.sort<\/samp><\/p>\n\n\n\n<p>\u5bf9\u4e8e sObjects\uff0c\u6392\u5e8f\u6309\u5347\u5e8f\u6392\u5217\uff0c\u5e76\u4f7f\u7528\u4e00\u7cfb\u5217\u6bd4\u8f83\u6b65\u9aa4 \u5728\u4e0b\u4e00\u8282\u4e2d\u6982\u8ff0\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u4e3a sObjects \u521b\u5efa\u81ea\u5b9a\u4e49\u6392\u5e8f\u987a\u5e8f \u5c06 sObject \u5305\u88c5\u5728\u5b9e\u73b0\u63a5\u53e3\u7684 Apex \u7c7b\u4e2d\u3002\u60a8\u8fd8\u53ef\u4ee5\u521b\u5efa\u81ea\u5b9a\u4e49 \u901a\u8fc7\u5c06\u4f5c\u4e3a\u53c2\u6570\u5b9e\u73b0\u7684\u7c7b\u4f20\u9012\u7ed9 sort \u65b9\u6cd5\u6765\u6392\u5e8f\u987a\u5e8f\u3002\u8bf7\u53c2\u9605\u00a0sObject \u7684\u81ea\u5b9a\u4e49\u6392\u5e8f\u987a\u5e8f\u3002<samp>ComparableComparator<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">sObjects \u7684\u9ed8\u8ba4\u6392\u5e8f\u987a\u5e8f<\/h2>\n\n\n\n<p>\u8be5\u65b9\u6cd5\u5bf9 sObjects \u8fdb\u884c\u6392\u5e8f \u5347\u5e8f\u5e76\u4f7f\u7528\u6709\u5e8f\u7684\u6b65\u9aa4\u5e8f\u5217\u6bd4\u8f83 sObjects \u6307\u5b9a\u4f7f\u7528\u7684\u6807\u7b7e\u6216\u5b57\u6bb5\u3002\u6bd4\u8f83\u4ece\u7b2c\u4e00\u6b65\u5f00\u59cb \u5e8f\u5217\uff0c\u5e76\u5728\u4f7f\u7528\u6307\u5b9a\u7684\u6807\u7b7e\u6216\u5b57\u6bb5\u5bf9\u4e24\u4e2a sObject \u8fdb\u884c\u6392\u5e8f\u65f6\u7ed3\u675f\u3002\u8fd9 \u4ee5\u4e0b\u662f\u4f7f\u7528\u7684\u6bd4\u8f83\u987a\u5e8f\uff1a<\/p>\n\n\n\n<p><samp>List.sort<\/samp><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>sObject \u7c7b\u578b\u7684\u6807\u7b7e\u3002\u4f8b\u5982\uff0c\u5c06\u663e\u793a Account sObject \u5728\u8054\u7cfb\u4eba\u4e4b\u524d\u3002<\/li>\n\n\n\n<li>\u201c\u540d\u79f0\u201d\u5b57\u6bb5\uff08\u5982\u679c\u9002\u7528\uff09\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5217\u8868\u5305\u542b\u4e24\u4e2a \u540d\u4e3a Alpha \u548c Beta \u7684\u5e10\u6237\uff0c\u5e10\u6237 Alpha \u5728\u5e10\u6237\u4e4b\u524d \u8bd5\u7528\u7248\u3002<\/li>\n\n\n\n<li>\u6807\u51c6\u5b57\u6bb5\uff0c\u4ece\u6309\u5b57\u6bcd\u987a\u5e8f\u6392\u5728\u7b2c\u4e00\u4f4d\u7684\u5b57\u6bb5\u5f00\u59cb \u987a\u5e8f\uff0c\u4f46 Id \u548c Name \u5b57\u6bb5\u9664\u5916\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e24\u4e2a\u5e10\u6237 \u5177\u6709\u76f8\u540c\u7684\u540d\u79f0\uff0c\u7528\u4e8e\u6392\u5e8f\u7684\u7b2c\u4e00\u4e2a\u6807\u51c6\u5b57\u6bb5\u662f \u5e10\u53f7\u3002<\/li>\n\n\n\n<li>\u81ea\u5b9a\u4e49\u5b57\u6bb5\uff0c\u4ece\u6309\u5b57\u6bcd\u987a\u5e8f\u6392\u5728\u7b2c\u4e00\u4f4d\u7684\u5b57\u6bb5\u5f00\u59cb \u6b21\u5e8f\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u4e24\u4e2a\u5e10\u6237\u5177\u6709\u76f8\u540c\u7684\u540d\u79f0\u548c \u76f8\u540c\u7684\u6807\u51c6\u5b57\u6bb5\uff0c\u5e76\u4e14\u6709\u4e24\u4e2a\u81ea\u5b9a\u4e49\u5b57\u6bb5\uff0cFieldA \u548c FieldB\uff0c\u9996\u5148\u4f7f\u7528 FieldA \u7684\u503c\u8fdb\u884c\u6392\u5e8f\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u5e76\u975e\u5fc5\u987b\u6267\u884c\u6b64\u5e8f\u5217\u4e2d\u7684\u6240\u6709\u6b65\u9aa4\u3002\u4f8b\u5982\uff0c\u5217\u8868 \u5305\u542b\u4e24\u4e2a\u76f8\u540c\u7c7b\u578b\u4e14\u5177\u6709\u552f\u4e00 Name \u503c\u7684 sObject \u7684\u6392\u5e8f\u4f9d\u636e \uff0c\u6392\u5e8f\u5728\u6b65\u9aa4 2 \u5904\u505c\u6b62\u3002\u5426\u5219\uff0c\u5982\u679c\u540d\u79f0\u76f8\u540c \u6216\u8005 sObject \u6ca1\u6709 Name \u5b57\u6bb5\uff0c\u5219\u6392\u5e8f\u5c06\u8f6c\u5230\u6b65\u9aa4 3 \u8fdb\u884c\u6392\u5e8f \u6309\u6807\u51c6\u5b57\u6bb5\u3002<\/p>\n\n\n\n<p><a><\/a>\u5bf9\u4e8e\u6587\u672c\u5b57\u6bb5\uff0c\u6392\u5e8f\u7b97\u6cd5\u4f7f\u7528 Unicode \u6392\u5e8f \u6b21\u5e8f\u3002\u6b64\u5916\uff0c\u5728\u6392\u5e8f\u987a\u5e8f\u4e2d\uff0c\u7a7a\u5b57\u6bb5\u4f4d\u4e8e\u975e\u7a7a\u5b57\u6bb5\u4e4b\u524d\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u5bf9\u5e10\u6237 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f\u7684\u793a\u4f8b\u3002\u6b64\u793a\u4f8b\u6f14\u793a Name \u5b57\u6bb5\u7528\u4e8e\u5c06 Acme \u5e10\u6237\u7f6e\u4e8e \u5217\u8868\u3002\u7531\u4e8e\u6709\u4e24\u4e2a\u540d\u4e3a sForce \u7684\u5e10\u6237\uff0c\u56e0\u6b64 Industry \u5b57\u6bb5\u7528\u4e8e\u6392\u5e8f \u8fd9\u4e9b\u5269\u4f59\u7684\u5e10\u6237\uff0c\u56e0\u4e3a \u201c\u884c\u4e1a \u201d\u5b57\u6bb5\u4f4d\u4e8e \u6309\u5b57\u6bcd\u987a\u5e8f\u6392\u5217\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Account&#91;] acctList = new List&lt;Account&gt;();        \nacctList.add( new Account(\n    Name='sForce',\n    Industry='Biotechnology',\n    Site='Austin'));\nacctList.add(new Account(\n    Name='sForce',\n    Industry='Agriculture',\n    Site='New York'));\nacctList.add(new Account(\n    Name='Acme'));\nSystem.debug(acctList);\n\nacctList.sort();\nAssert.areEqual('Acme', acctList&#91;0].Name);\nAssert.areEqual('sForce', acctList&#91;1].Name);\nAssert.areEqual('Agriculture', acctList&#91;1].Industry);\nAssert.areEqual('sForce', acctList&#91;2].Name);\nAssert.areEqual('Biotechnology', acctList&#91;2].Industry);\nSystem.debug(acctList);<\/code><\/pre>\n\n\n\n<p>\u6b64\u793a\u4f8b\u4e0e\u4e0a\u4e00\u4e2a\u793a\u4f8b\u7c7b\u4f3c\uff0c\u53ea\u4e0d\u8fc7\u5b83\u4f7f\u7528\u4e86 Merchandise__c \u81ea\u5b9a\u4e49\u5bf9\u8c61\u3002\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u4f7f\u7528 Name \u5b57\u6bb5\u6765\u653e\u7f6e\u7b14\u8bb0\u672c \u5546\u54c1\u5728\u5217\u8868\u4e2d\u6392\u5728\u94a2\u7b14\u4e4b\u524d\u3002\u56e0\u4e3a\u5546\u54c1\u6709\u4e24\u4e2a sObject \u5bf9\u4e8e\u201c\u7b14\u201d\u7684\u201c\u540d\u79f0\u201d\u5b57\u6bb5\u503c\uff0c\u201c\u8bf4\u660e\u201d\u5b57\u6bb5\u7528\u4e8e\u5bf9\u5b83\u4eec\u8fdb\u884c\u6392\u5e8f \u5269\u4f59\u5546\u54c1\u3002\u201c\u8bf4\u660e\u201d\u5b57\u6bb5\u7528\u4e8e\u6392\u5e8f\uff0c\u56e0\u4e3a\u5b83 \u6309\u5b57\u6bcd\u987a\u5e8f\u4f4d\u4e8e Price \u548c Total_Inventory \u5b57\u6bb5\u4e4b\u524d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Merchandise__c&#91;] merchList = new List&lt;Merchandise__c&gt;();        \nmerchList.add( new Merchandise__c(\n    Name='Pens',\n    Description__c='Red pens',\n    Price__c=2,\n    Total_Inventory__c=1000));\nmerchList.add( new Merchandise__c(\n    Name='Notebooks',\n    Description__c='Cool notebooks',\n    Price__c=3.50,\n    Total_Inventory__c=2000));\nmerchList.add( new Merchandise__c(\n    Name='Pens',\n    Description__c='Blue pens',\n    Price__c=1.75,\n    Total_Inventory__c=800));\nSystem.debug(merchList);\n\nmerchList.sort();\nAssert.areEqual('Notebooks', merchList&#91;0].Name);\nAssert.areEqual('Pens', merchList&#91;1].Name);\nAssert.areEqual('Blue pens', merchList&#91;1].Description__c);\nAssert.areEqual('Pens', merchList&#91;2].Name);\nAssert.areEqual('Red pens', merchList&#91;2].Description__c);\nSystem.debug(merchList);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><a><\/a>sObjects \u7684\u81ea\u5b9a\u4e49\u6392\u5e8f\u987a\u5e8f<\/h2>\n\n\n\n<p>\u82e5\u8981\u4e3a\u5217\u8868\u4e2d\u7684 sObject \u521b\u5efa\u81ea\u5b9a\u4e49\u6392\u5e8f\u987a\u5e8f\uff0c\u8bf7\u5b9e\u73b0\u63a5\u53e3\u5e76\u5c06\u5176\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012 \u5230\u65b9\u6cd5\u3002<samp>Comparator<\/samp><samp>List.sort<\/samp><\/p>\n\n\n\n<p>\u6216\u8005\uff0c\u4e3a sObject \u521b\u5efa\u4e00\u4e2a\u5305\u88c5\u7c7b\u5e76\u5b9e\u73b0\u63a5\u53e3\u3002\u5305\u88c5\u7c7b\u5305\u542b \u6240\u8ba8\u8bba\u7684 sObject \u5e76\u5b9e\u73b0\u6307\u5b9a\u6392\u5e8f\u903b\u8f91\u7684\u65b9\u6cd5\u3002<samp>Comparable<\/samp><samp>Comparable.compareTo<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b<\/h2>\n\n\n\n<p>\u6b64\u793a\u4f8b\u5b9e\u73b0\u57fa\u4e8e\u201c\u91d1\u989d\u201d\u5b57\u6bb5\u6bd4\u8f83\u4e24\u4e2a\u5546\u673a\u7684\u63a5\u53e3\u3002<samp>Comparator<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class OpportunityComparator implements Comparator&lt;Opportunity&gt; {\n    public Integer compare(Opportunity o1, Opportunity o2) {\n        \/\/ The return value of 0 indicates that both elements are equal.\n        Integer returnValue = 0;\n        \n        if(o1 == null &amp;&amp; o2 == null) {\n            returnValue = 0;\n        } else if(o1 == null) {\n            \/\/ nulls-first implementation\n            returnValue = -1; \n        } else if(o2 == null) {\n            \/\/ nulls-first implementation\n            returnValue = 1;\n        } else if ((o1.Amount == null) &amp;&amp; (o2.Amount == null)) {\n            \/\/ both have null Amounts\n            returnValue = 0;\n        } else if (o1.Amount == null){\n            \/\/ nulls-first implementation\n            returnValue = -1;\n        } else if (o2.Amount == null){\n            \/\/ nulls-first implementation\n            returnValue = 1;\n        } else if (o1.Amount &lt; o2.Amount) {\n            \/\/ Set return value to a negative value.\n            returnValue = -1;\n        } else if (o1.Amount &gt; o2.Amount) {\n            \/\/ Set return value to a positive value.\n            returnValue = 1;\n        }\n        return returnValue;\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u6d4b\u8bd5\u5bf9\u5bf9\u8c61\u5217\u8868\u8fdb\u884c\u6392\u5e8f \u5e76\u9a8c\u8bc1\u5217\u8868\u5143\u7d20\u662f\u5426\u6309\u5546\u673a\u6570\u91cf\u6392\u5e8f\u3002<samp>Comparator<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@isTest\nprivate class OpportunityComparator_Test {\n \n    @isTest\n    static void sortViaComparator() {\n        \/\/ Add the opportunity wrapper objects to a list.\n        List&lt;Opportunity&gt; oppyList = new List&lt;Opportunity&gt;();\n        Date closeDate = Date.today().addDays(10);\n        oppyList.add( new Opportunity(\n            Name='Edge Installation',\n            CloseDate=closeDate,\n            StageName='Prospecting',\n            Amount=50000));\n        oppyList.add( new Opportunity(\n            Name='United Oil Installations',\n            CloseDate=closeDate,\n            StageName='Needs Analysis',\n            Amount=100000));\n        oppyList.add( new Opportunity(\n            Name='Grand Hotels SLA',\n            CloseDate=closeDate,\n            StageName='Prospecting',\n            Amount=25000));\n        oppyList.add(null);\n        \n        \/\/ Sort the objects using the Comparator implementation\n        oppyList.sort(new OpportunityComparator());\n        \/\/ Verify the sort order\n        Assert.isNull(oppyList&#91;0]);\n        Assert.areEqual('Grand Hotels SLA', oppyList&#91;1].Name);\n        Assert.areEqual(25000, oppyList&#91;1].Amount);\n        Assert.areEqual('Edge Installation', oppyList&#91;2].Name);\n        Assert.areEqual(50000, oppyList&#91;2].Amount);\n        Assert.areEqual('United Oil Installations', oppyList&#91;3].Name);\n        Assert.areEqual(100000, oppyList&#91;3].Amount);\n        \/\/ Write the sorted list contents to the debug log.\n        System.debug(oppyList);\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b<\/h2>\n\n\n\n<p>\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u4e3a Opportunity \u521b\u5efa\u5305\u88c5\u7c7b\u3002\u6b64\u7c7b\u4e2d\u8be5\u65b9\u6cd5\u7684\u5b9e\u73b0\u6bd4\u8f83\u4e86\u4e24\u4e2a \u57fa\u4e8e\u201c\u91d1\u989d\u201d\u5b57\u6bb5\u7684\u5546\u673a &#8211; \u5305\u542b\u7684\u7c7b\u6210\u5458\u53d8\u91cf \u5728\u672c\u4f8b\u4e2d\uff0c\u5c06 Opportunity \u5bf9\u8c61\u4f20\u9012\u5230\u65b9\u6cd5\u4e2d\u3002<samp>Comparable<\/samp><samp>compareTo<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class OpportunityWrapper implements Comparable {\n\n    public Opportunity oppy;\n    \n    \/\/ Constructor\n    public OpportunityWrapper(Opportunity op) {\n    \t\/\/ Guard against wrapping a null \n    \tif(op == null) {\n    \t\tException ex = new NullPointerException();\n    \t\tex.setMessage('Opportunity argument cannot be null'); \n    \t\tthrow ex;\n    \t}\n        oppy = op;\n    }\n    \n    \/\/ Compare opportunities based on the opportunity amount.\n    public Integer compareTo(Object compareTo) {\n        \/\/ Cast argument to OpportunityWrapper\n        OpportunityWrapper compareToOppy = (OpportunityWrapper)compareTo;\n        \n        \/\/ The return value of 0 indicates that both elements are equal.\n        Integer returnValue = 0;\n        if ((oppy.Amount == null) &amp;&amp; (compareToOppy.oppy.Amount == null)) {\n            \/\/ both wrappers have null Amounts\n            returnValue = 0;\n        } else if ((oppy.Amount == null) &amp;&amp; (compareToOppy.oppy.Amount != null)){\n            \/\/ nulls-first implementation\n            returnValue = -1;\n        } else if ((oppy.Amount != null) &amp;&amp; (compareToOppy.oppy.Amount == null)){\n            \/\/ nulls-first implementation\n            returnValue = 1;\n        } else if (oppy.Amount &gt; compareToOppy.oppy.Amount) {\n            \/\/ Set return value to a positive value.\n            returnValue = 1;\n        } else if (oppy.Amount &lt; compareToOppy.oppy.Amount) {\n            \/\/ Set return value to a negative value.\n            returnValue = -1;\n        } \n        return returnValue;\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u6d4b\u8bd5\u5bf9\u5bf9\u8c61\u5217\u8868\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u9a8c\u8bc1\u5217\u8868\u5143\u7d20\u662f\u5426\u6309\u5546\u673a\u6392\u5e8f \u91cf\u3002<samp>OpportunityWrapper<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@isTest \nprivate class OpportunityWrapperTest {\n    static testmethod void test1() {\n        \/\/ Add the opportunity wrapper objects to a list.\n        OpportunityWrapper&#91;] oppyList = new List&lt;OpportunityWrapper&gt;();\n        Date closeDate = Date.today().addDays(10);\n        oppyList.add( new OpportunityWrapper(new Opportunity(\n            Name='Edge Installation',\n            CloseDate=closeDate,\n            StageName='Prospecting',\n            Amount=50000)));\n        oppyList.add( new OpportunityWrapper(new Opportunity(\n            Name='United Oil Installations',\n            CloseDate=closeDate,\n            StageName='Needs Analysis',\n            Amount=100000)));\n        oppyList.add( new OpportunityWrapper(new Opportunity(\n            Name='Grand Hotels SLA',\n            CloseDate=closeDate,\n            StageName='Prospecting',\n            Amount=25000)));\n        \n        \/\/ Sort the wrapper objects using the implementation of the \n        \/\/ compareTo method.\n        oppyList.sort();\n        \n        \/\/ Verify the sort order\n        Assert.areEqual('Grand Hotels SLA', oppyList&#91;0].oppy.Name);\n        Assert.areEqual(25000, oppyList&#91;0].oppy.Amount);\n        Assert.areEqual('Edge Installation', oppyList&#91;1].oppy.Name);\n        Assert.areEqual(50000, oppyList&#91;1].oppy.Amount);\n        Assert.areEqual('United Oil Installations', oppyList&#91;2].oppy.Name);\n        Assert.areEqual(100000, oppyList&#91;2].oppy.Amount);\n        \n        \/\/ Write the sorted list contents to the debug log.\n        System.debug(oppyList);\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f<\/h2>\n\n\n\n<p>\u4e0e Java \u4e00\u6837\uff0c\u53ef\u4ee5\u4f7f\u7528 method \u6269\u5c55 sObject \u548c list \u8868\u8fbe\u5f0f \u5f15\u7528\u548c\u5217\u8868\u8868\u8fbe\u5f0f\uff0c\u4ee5\u5f62\u6210\u65b0\u7684\u8868\u8fbe\u5f0f\u3002\u5728\u4ee5\u4e0b\u793a\u4f8b\u4e2d\uff0c\u5305\u542b\u957f\u5ea6\u7684\u65b0\u53d8\u91cf \u7684\u65b0\u5e10\u6237\u540d\u79f0\u5206\u914d\u7ed9 \u3002<\/p>\n\n\n\n<p><samp>acctNameLength<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Integer acctNameLength = new Account&#91;]{new Account(Name='Acme')}&#91;0].Name.length();<\/code><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762\uff0c\u751f\u6210\u4e00\u4e2a\u5217\u8868\u3002<samp>new&nbsp;Account[]<\/samp><\/p>\n\n\n\n<p>\u8be5\u5217\u8868\u7531\u8bed\u53e5\u586b\u5145\u4e00\u4e2a\u5143\u7d20\u3002<samp>new<\/samp><samp>{new&nbsp;Account(name=&#8217;Acme&#8217;)}<\/samp><\/p>\n\n\n\n<p>\u9879\u76ee 0 \u662f\u5217\u8868\u4e2d\u7684\u7b2c\u4e00\u9879\uff0c\u7136\u540e\u7531\u4e0b\u4e00\u4e2a\u9879\u76ee\u8bbf\u95ee \u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\u3002<samp>[0]<\/samp><\/p>\n\n\n\n<p>\u8bbf\u95ee\u5217\u8868\u4e2d sObject \u7684\u540d\u79f0\uff0c\u540e\u8ddf \u8fd4\u56de\u957f\u5ea6\u7684\u65b9\u6cd5\u3002<samp>name.length()<\/samp>\u5728\u4ee5\u4e0b\u793a\u4f8b\u4e2d\uff0c\u5df2\u79fb\u81f3 lower \u7684\u540d\u79f0 \u5927\u5c0f\u5199\u3002SOQL \u8bed\u53e5\u8fd4\u56de\u4e00\u4e2a\u5217\u8868\uff0c\u5176\u4e2d\u7b2c\u4e00\u4e2a\u5143\u7d20\uff08\u7d22\u5f15\u4e3a 0\uff09 \u53ef\u901a\u8fc7 \u8bbf\u95ee\u3002 \u63a5\u4e0b\u6765\uff0c\u8bbf\u95ee\u201c\u540d\u79f0\u201d\u5b57\u6bb5\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5c0f\u5199 \u8868\u8fbe\u3002<\/p>\n\n\n\n<p><samp>[0]<\/samp><samp>.Name.toLowerCase()<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String nameChange = &#91;SELECT Name FROM Account]&#91;0].Name.toLowerCase();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5bf9\u8c61\u96c6<\/h2>\n\n\n\n<p>\u96c6\u5408\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002\u96c6\u5408\u5305\u542b\u72ec\u7279\u7684\u5143\u7d20\u3002\u786e\u5b9a sObject \u7684\u552f\u4e00\u6027 \u901a\u8fc7\u6bd4\u8f83\u5bf9\u8c61\u7684\u5b57\u6bb5\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5c1d\u8bd5 \u5c06\u4e24\u4e2a\u540c\u540d\u7684\u5e10\u6237\u6dfb\u52a0\u5230\u4e00\u4e2a\u96c6\u5408\u4e2d\uff0c\u6ca1\u6709\u5176\u4ed6\u5b57\u6bb5 set\uff0c\u5219\u8be5\u96c6\u5408\u4e2d\u4ec5\u6dfb\u52a0\u4e00\u4e2a sObject\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create two accounts, a1 and a2\nAccount a1 = new account(name='MyAccount');\nAccount a2 = new account(name='MyAccount');\n\n\/\/ Add both accounts to the new set \nSet&lt;Account&gt; accountSet = new Set&lt;Account&gt;{a1, a2};\n\n\/\/ Verify that the set only contains one item\nSystem.assertEquals(accountSet.size(), 1);<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u60a8\u5411\u5176\u4e2d\u4e00\u4e2a\u5e10\u6237\u6dfb\u52a0\u63cf\u8ff0\uff0c\u5219\u4f1a\u5c06\u5176\u89c6\u4e3a \u552f\u4e00\uff0c\u5e76\u4e14\u4e24\u4e2a\u5e10\u6237\u90fd\u4f1a\u6dfb\u52a0\u5230\u96c6\u5408\u4e2d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create two accounts, a1 and a2, and add a description to a2\nAccount a1 = new account(name='MyAccount');\nAccount a2 = new account(name='MyAccount', description='My test account');\n\n\/\/ Add both accounts to the new set\nSet&lt;Account&gt; accountSet = new Set&lt;Account&gt;{a1, a2};\n\n\/\/ Verify that the set contains two items\nSystem.assertEquals(accountSet.size(), 2);<\/code><\/pre>\n\n\n\n<p>\u8b66\u544a<\/p>\n\n\n\n<p>\u5982\u679c set \u5143\u7d20\u662f\u5bf9\u8c61\uff0c\u5e76\u4e14\u8fd9\u4e9b\u5bf9\u8c61 \u6dfb\u52a0\u5230\u96c6\u5408\u540e\u66f4\u6539\uff0c\u5219\u627e\u4e0d\u5230\u5b83\u4eec \u4f8b\u5982\uff0c\u5728\u4f7f\u7528 OR \u65b9\u6cd5\u65f6\uff0c\u7531\u4e8e\u5b57\u6bb5\u503c\u5df2\u66f4\u6539\u3002<samp>contains<\/samp><samp>containsAll<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">sObjects \u7684\u6620\u5c04<\/h2>\n\n\n\n<p>\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject \u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002\u6620\u5c04\u53ef\u4ee5\u5728\u5176\u952e\u548c\u503c\u4e2d\u4fdd\u5b58 sObject\u3002\u5730\u56fe\u952e \u8868\u793a\u6620\u5c04\u5230\u6620\u5c04\u503c\u7684\u552f\u4e00\u503c\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a \u901a\u7528\u952e\u662f\u6620\u5c04\u5230\u5e10\u6237\u7684 ID\uff08\u7279\u5b9a\u7684 sObject \u7c7b\u578b\uff09\u3002\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u5b9a\u4e49\u5176\u952e\u7c7b\u578b\u4e3a ID\uff0c\u5176\u503c\u7684\u7c7b\u578b\u4e3a Account\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Map&lt;ID, Account&gt; m = new Map&lt;ID, Account&gt;();<\/code><\/pre>\n\n\n\n<p>\u4e0e\u57fa\u5143\u7c7b\u578b\u4e00\u6837\uff0c\u60a8\u53ef\u4ee5\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u586b\u5145\u6620\u5c04\u952e\u503c\u5bf9 \u6620\u5c04\u662f\u4f7f\u7528\u5927\u62ec\u53f7 \uff08\uff09 \u8bed\u6cd5\u58f0\u660e\u7684\u3002\u5728\u5927\u62ec\u53f7\u5185\uff0c \u9996\u5148\u6307\u5b9a\u952e\uff0c\u7136\u540e\u4f7f\u7528 \u6307\u5b9a\u8be5\u952e\u7684\u503c\u3002\u672c\u793a\u4f8b\u521b\u5efa \u5c06\u6574\u6570\u6dfb\u52a0\u5230\u5e10\u6237\u5217\u8868\uff0c\u5e76\u4f7f\u7528\u5e10\u6237\u5217\u8868\u6dfb\u52a0\u4e00\u4e2a\u6761\u76ee \u521b\u5efa\u65f6\u95f4\u8f83\u65e9\u3002<samp>{}<\/samp><samp>=&gt;<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Account&#91;] accs = new Account&#91;5]; \/\/ Account&#91;] is synonymous with List&lt;Account&gt;\nMap&lt;Integer, List&lt;Account&gt;&gt; m4 = new Map&lt;Integer, List&lt;Account&gt;&gt;{1 =&gt; accs};<\/code><\/pre>\n\n\n\n<p>\u6620\u5c04\u5141\u8bb8\u5728\u5176\u952e\u4e2d\u4f7f\u7528 sObject\u3002\u4ec5\u5f53 sObject \u5b57\u6bb5\u65f6\uff0c\u624d\u5fc5\u987b\u5728\u952e\u4e2d\u4f7f\u7528 sObject \u503c\u4e0d\u4f1a\u6539\u53d8\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ece SOQL \u67e5\u8be2\u81ea\u52a8\u586b\u5145\u6620\u5c04\u6761\u76ee<\/h2>\n\n\n\n<p>\u4f7f\u7528 SOQL \u67e5\u8be2\u65f6\uff0c\u53ef\u4ee5\u4ece SOQL \u8fd4\u56de\u7684\u7ed3\u679c\u586b\u5145\u6620\u5c04 \u67e5\u8be2\u3002\u6620\u5c04\u952e\u5fc5\u987b\u4f7f\u7528 ID \u6216 String \u6570\u636e\u7c7b\u578b\u58f0\u660e\uff0c\u5e76\u4e14\u6620\u5c04 value \u5fc5\u987b\u58f0\u660e\u4e3a sObject \u6570\u636e\u7c7b\u578b\u3002\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u4ece\u67e5\u8be2\u586b\u5145\u65b0\u6620\u5c04\u3002\u5728 \u4f8b\u5982\uff0cSOQL \u67e5\u8be2\u8fd4\u56de\u5e26\u6709\u5176 \u548c \u5b57\u6bb5\u7684\u5e10\u6237\u5217\u8868\u3002\u64cd\u4f5c\u5458\u4f7f\u7528\u8fd4\u56de\u7684\u5e10\u6237\u5217\u8868\u6765\u521b\u5efa\u5730\u56fe\u3002<\/p>\n\n\n\n<p><samp>Id<\/samp><samp>Name<\/samp><samp>new<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Populate map from SOQL query\nMap&lt;ID, Account&gt; m = new Map&lt;ID, Account&gt;(&#91;SELECT Id, Name FROM Account LIMIT 10]);\n\/\/ After populating the map, iterate through the map entries\nfor (ID idKey : m.keyset()) {\n    Account a = m.get(idKey);\n    System.debug(a);\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u6620\u5c04\u7c7b\u578b\u7684\u4e00\u79cd\u5e38\u89c1\u7528\u6cd5\u662f\u5185\u5b58\u4e2d \u4e24\u4e2a\u8868\u4e4b\u95f4\u7684\u201c\u8054\u63a5\u201d\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u4f5c\u4e3a\u591a\u4e2a\u793e\u533a\u6210\u5458\u7684\u7528\u6237\u7684\u6700\u8fd1\u67e5\u770b\u7684\u8bb0\u5f55\u4e0d\u80fd\u662f \u901a\u8fc7 Apex \u81ea\u52a8\u68c0\u7d22\u5230\u5730\u56fe\u4e2d\u3002\u8fd9\u662f\u56e0\u4e3a\u7528\u6237\u7684\u8bb0\u5f55 \u4e0d\u540c\u7684\u7f51\u7edc\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5730\u56fe\u4e0d\u652f\u6301\u7684\u91cd\u590d ID\u3002\u67e5\u770b\u66f4\u591a \u4fe1\u606f\uff0c\u8bf7\u53c2\u9605<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.246.0.object_reference.meta\/object_reference\/sforce_api_objects_recentlyviewed.htm\" target=\"_blank\" rel=\"noreferrer noopener\">\u6700\u8fd1\u67e5\u770b<\/a>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u7528 Map \u65b9\u6cd5<\/h2>\n\n\n\n<p>\u8be5\u7c7b\u516c\u5f00\u4e86\u5404\u79cd\u65b9\u6cd5 \u53ef\u7528\u4e8e\u5904\u7406\u5730\u56fe\u5143\u7d20\uff0c\u4f8b\u5982\u6dfb\u52a0\u3001\u5220\u9664\u3001 \u6216\u68c0\u7d22\u5143\u7d20\u3002\u6b64\u793a\u4f8b\u4f7f\u7528 Map \u65b9\u6cd5\u6dfb\u52a0\u65b0\u5143\u7d20 \u5e76\u4ece\u5730\u56fe\u4e2d\u68c0\u7d22\u73b0\u6709\u5143\u7d20\u3002\u6b64\u793a\u4f8b\u8fd8\u68c0\u67e5 \u5bf9\u4e8e\u952e\u7684\u5b58\u5728\uff0c\u5e76\u83b7\u53d6\u6240\u6709\u952e\u7684\u96c6\u5408\u3002\u5730\u56fe\u5728 \u6b64\u793a\u4f8b\u6709\u4e00\u4e2a\u5143\u7d20\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u6574\u6570\u952e\u548c\u4e00\u4e2a\u5e10\u6237\u503c\u3002<samp>Map<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Account myAcct = new Account();                        \/\/Define a new account\nMap&lt;Integer, Account&gt; m = new Map&lt;Integer, Account&gt;(); \/\/ Define a new map\nm.put(1, myAcct);                  \/\/ Insert a new key-value pair in the map\nSystem.assert(!m.containsKey(3));  \/\/ Assert that the map contains a key\nAccount a = m.get(1);              \/\/ Retrieve a value, given a particular key\nSet&lt;Integer&gt; s = m.keySet();       \/\/ Return a set that contains all of the keys in the map<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>sObject \u6620\u5c04\u6ce8\u610f\u4e8b\u9879<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">sObject \u6620\u5c04\u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<p>\u4f7f\u7528 sObject \u4f5c\u4e3a\u6620\u5c04\u952e\u65f6\u8981\u5c0f\u5fc3\u3002sObject \u7684\u952e\u5339\u914d \u57fa\u4e8e\u6240\u6709 sObject \u5b57\u6bb5\u503c\u7684\u6bd4\u8f83\u3002\u5982\u679c\u4e00\u4e2a\u6216 \u5c06 sObject \u6dfb\u52a0\u5230\u5730\u56fe\u540e\uff0c\u66f4\u591a\u5b57\u6bb5\u503c\u53d1\u751f\u53d8\u5316\uff0c\u5c1d\u8bd5 \u8981\u4ece\u6620\u5c04\u4e2d\u68c0\u7d22\u6b64 sObject\uff0c\u5219\u8fd4\u56de \u3002\u8fd9\u662f\u56e0\u4e3a\u4fee\u6539\u540e\u7684 \u7531\u4e8e\u5b57\u6bb5\u503c\u4e0d\u540c\uff0c\u5728\u6620\u5c04\u4e2d\u627e\u4e0d\u5230 sObject\u3002 \u5982\u679c\u663e\u5f0f\u66f4\u6539 sObject \u4e0a\u7684\u5b57\u6bb5\uff0c\u6216\u8005 \u5982\u679c\u7cfb\u7edf\u9690\u5f0f\u66f4\u6539\u4e86 sObject \u5b57\u6bb5;\u4f8b\u5982 \u63d2\u5165 sObject \u540e\uff0csObject \u53d8\u91cf\u5177\u6709 ID \u5b57\u6bb5 \u81ea\u52a8\u586b\u5145\u3002\u5c1d\u8bd5\u4ece\u5b83\u6240\u5230\u7684\u6620\u5c04\u4e2d\u83b7\u53d6\u6b64\u5bf9\u8c61 \u5728\u64cd\u4f5c\u4e0d\u4f1a\u751f\u6210\u6620\u5c04\u6761\u76ee\u4e4b\u524d\u6dfb\u52a0\uff0c\u5982\u672c\u793a\u4f8b\u6240\u793a\u3002<\/p>\n\n\n\n<p><samp>null<\/samp><samp>insert<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Create an account and add it to the map\nAccount a1 = new Account(Name='A1');\nMap&lt;sObject, Integer&gt; m = new Map&lt;sObject, Integer&gt;{\na1 =&gt; 1};\n    \n\/\/ Get a1's value from the map.\n\/\/ Returns the value of 1.\nSystem.assertEquals(1, m.get(a1));\n\/\/ Id field is null.\nSystem.assertEquals(null, a1.Id);\n\n\/\/ Insert a1.\n\/\/ This causes the ID field on a1 to be auto-filled\ninsert a1;\n\/\/ Id field is now populated.\nSystem.assertNotEquals(null, a1.Id);\n\n\/\/ Get a1's value from the map again.\n\/\/ Returns null because Map.get(sObject) doesn't find\n\/\/ the entry based on the sObject with an auto-filled ID.\n\/\/ This is because when a1 was originally added to the map\n\/\/ before the insert operation, the ID of a1 was null.\nSystem.assertEquals(null, m.get(a1));<\/code><\/pre>\n\n\n\n<p>\u53e6\u4e00\u79cd\u60c5\u51b5 \u5176\u4e2d\u81ea\u52a8\u586b\u5145\u7684 sObject \u5b57\u6bb5\u4f4d\u4e8e\u89e6\u53d1\u5668\u4e2d\uff0c\u4f8b\u5982\uff0c\u5f53 \u5bf9 sObject \u4f7f\u7528\u63d2\u5165\u89e6\u53d1\u5668\u4e4b\u524d\u548c\u4e4b\u540e\u3002\u5982\u679c\u8fd9\u4e9b\u89e6\u53d1\u5668 \u5171\u4eab\u4e00\u4e2a\u7c7b\u4e2d\u5b9a\u4e49\u7684\u9759\u6001\u6620\u5c04\uff0c\u5e76\u5c06 \u4e2d\u7684 sObject \u6dfb\u52a0\u5230\u8be5\u6620\u5c04\u4e2d \u5728 before \u89e6\u53d1\u5668\u4e2d\uff0c\u5728 after \u89e6\u53d1\u5668\u4e2d\u627e\u4e0d\u5230 \u6620\u5c04\uff0c\u56e0\u4e3a\u4e24\u7ec4 sObject \u7684\u5b57\u6bb5\u4e0d\u540c \u662f\u81ea\u52a8\u586b\u5145\u7684\u3002after \u89e6\u53d1\u5668\u4e2d\u7684 sObjects \u5728\u63d2\u5165\u540e\u586b\u5145\u4e86\u7cfb\u7edf\u5b57\u6bb5\uff0c \u5373\uff1aID\u3001CreatedDate\u3001CreatedById\u3001LastModifiedDate\u3001LastModifiedById\u3001 \u548c SystemModStamp\u3002<\/p>\n\n\n\n<p><samp>Trigger.New<\/samp><samp>Trigger.New<\/samp><samp>Trigger.New<\/samp><\/p>\n\n\n\n<p><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/apex_sobject_collections.htm\">ref<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002<\/p>\n<p>sObjects \u5217\u8868\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects<br \/>\n\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002<\/p>\n<p>\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0sObject<br \/>\n\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002List.sort<\/p>\n<p>\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f<\/p>\n<p>\u5bf9\u8c61<br \/>\n\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002<\/p>\n<p>sObject\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject<br \/>\n\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002<\/p>\n","protected":false},"author":1,"featured_media":3661,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[199],"tags":[],"class_list":["post-3660","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apex-"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>sObject \u96c6\u5408 - \u767d\u767d\u968f\u7b14<\/title>\n<meta name=\"description\" content=\"\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002sObjects \u5217\u8868\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0sObject\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002List.sort\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f\u5bf9\u8c61\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002sObject\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.ponybai.com\/?p=3660\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"sObject \u96c6\u5408 - \u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"og:description\" content=\"\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002sObjects \u5217\u8868\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0sObject\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002List.sort\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f\u5bf9\u8c61\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002sObject\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.ponybai.com\/?p=3660\" \/>\n<meta property=\"og:site_name\" content=\"\u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-28T10:06:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-21T10:19:54+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2023\/11\/sobject\u96c6\u5408.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1206\" \/>\n\t<meta property=\"og:image:height\" content=\"214\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"ponybai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"ponybai\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3660#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3660\"},\"author\":{\"name\":\"ponybai\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"headline\":\"sObject \u96c6\u5408\",\"datePublished\":\"2023-11-28T10:06:40+00:00\",\"dateModified\":\"2023-11-21T10:19:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3660\"},\"wordCount\":223,\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"articleSection\":[\"Apex \u5f00\u53d1\u4eba\u5458\u6307\u5357\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3660\",\"url\":\"http:\/\/www.ponybai.com\/?p=3660\",\"name\":\"sObject \u96c6\u5408 - \u767d\u767d\u968f\u7b14\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/#website\"},\"datePublished\":\"2023-11-28T10:06:40+00:00\",\"dateModified\":\"2023-11-21T10:19:54+00:00\",\"description\":\"\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002sObjects \u5217\u8868\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0sObject\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002List.sort\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f\u5bf9\u8c61\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002sObject\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002\",\"breadcrumb\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3660#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.ponybai.com\/?p=3660\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3660#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/www.ponybai.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"sObject \u96c6\u5408\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ponybai.com\/#website\",\"url\":\"http:\/\/www.ponybai.com\/\",\"name\":\"\u767d\u767d\u968f\u7b14\",\"description\":\"Salesforce\u5b98\u65b9\u8bb2\u5e08\",\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ponybai.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\",\"name\":\"ponybai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"contentUrl\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"width\":248,\"height\":248,\"caption\":\"ponybai\"},\"logo\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/121.37.188.161\"],\"url\":\"http:\/\/www.ponybai.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"sObject \u96c6\u5408 - \u767d\u767d\u968f\u7b14","description":"\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002sObjects \u5217\u8868\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0sObject\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002List.sort\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f\u5bf9\u8c61\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002sObject\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.ponybai.com\/?p=3660","og_locale":"zh_CN","og_type":"article","og_title":"sObject \u96c6\u5408 - \u767d\u767d\u968f\u7b14","og_description":"\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002sObjects \u5217\u8868\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0sObject\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002List.sort\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f\u5bf9\u8c61\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002sObject\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002","og_url":"http:\/\/www.ponybai.com\/?p=3660","og_site_name":"\u767d\u767d\u968f\u7b14","article_published_time":"2023-11-28T10:06:40+00:00","article_modified_time":"2023-11-21T10:19:54+00:00","og_image":[{"width":1206,"height":214,"url":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2023\/11\/sobject\u96c6\u5408.png","type":"image\/png"}],"author":"ponybai","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"ponybai","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.ponybai.com\/?p=3660#article","isPartOf":{"@id":"http:\/\/www.ponybai.com\/?p=3660"},"author":{"name":"ponybai","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"headline":"sObject \u96c6\u5408","datePublished":"2023-11-28T10:06:40+00:00","dateModified":"2023-11-21T10:19:54+00:00","mainEntityOfPage":{"@id":"http:\/\/www.ponybai.com\/?p=3660"},"wordCount":223,"publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"articleSection":["Apex \u5f00\u53d1\u4eba\u5458\u6307\u5357"],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/www.ponybai.com\/?p=3660","url":"http:\/\/www.ponybai.com\/?p=3660","name":"sObject \u96c6\u5408 - \u767d\u767d\u968f\u7b14","isPartOf":{"@id":"http:\/\/www.ponybai.com\/#website"},"datePublished":"2023-11-28T10:06:40+00:00","dateModified":"2023-11-21T10:19:54+00:00","description":"\u60a8\u53ef\u4ee5\u5728\u5217\u8868\u3001\u96c6\u548c\u6620\u5c04\u4e2d\u7ba1\u7406 sObject\u3002sObjects \u5217\u8868\u00a0\u5217\u8868\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u4e2d\u7684 sObjects\u3002sObject \u5217\u8868\u53ef\u7528\u4e8e\u6279\u91cf\u5904\u7406\u6570\u636e\u3002\u5bf9 sObject \u5217\u8868\u8fdb\u884c\u6392\u5e8f \u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u00a0sObject\u5217\u8868\u8fdb\u884c\u6392\u5e8f\u3002List.sort\u6269\u5c55 sObject \u548c\u5217\u8868\u8868\u8fbe\u5f0f\u5bf9\u8c61\u96c6 \u96c6\u53ef\u4ee5\u5305\u542b sObject \u4ee5\u53ca\u5176\u4ed6\u7c7b\u578b\u7684\u5143\u7d20\u3002sObject\u00a0\u6620\u5c04\u6620\u5c04\u952e\u548c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec sObject\u7c7b\u578b\uff0c\u4f8b\u5982 Account\u3002","breadcrumb":{"@id":"http:\/\/www.ponybai.com\/?p=3660#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.ponybai.com\/?p=3660"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.ponybai.com\/?p=3660#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/www.ponybai.com\/"},{"@type":"ListItem","position":2,"name":"sObject \u96c6\u5408"}]},{"@type":"WebSite","@id":"http:\/\/www.ponybai.com\/#website","url":"http:\/\/www.ponybai.com\/","name":"\u767d\u767d\u968f\u7b14","description":"Salesforce\u5b98\u65b9\u8bb2\u5e08","publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ponybai.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883","name":"ponybai","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/","url":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","contentUrl":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","width":248,"height":248,"caption":"ponybai"},"logo":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/121.37.188.161"],"url":"http:\/\/www.ponybai.com\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3660"}],"version-history":[{"count":1,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3660\/revisions"}],"predecessor-version":[{"id":3662,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3660\/revisions\/3662"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/media\/3661"}],"wp:attachment":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3660"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}