.SalesForce in a brief Schema class

What is a .Schema and Schema NameSpace

In SalesForce Schema refers to the various relationships between application objects (Object), and object.
Schema NameSpace contains a lot of classes and methods, these classes and methods, some basic information can access the Schema.

.Schema two commonly used classes and methods

Contains many classes and methods in the Schema NameSpace, where it will not have to do all the classes and methods introduced, only a few ways to do a brief introduction of several classes.

1.Schema.getGlobalDescribe method ``
This method returns a system all the sObject Map, wherein the key is sObject Name, value is sObject token.
The need to explain what is token, token of the Chinese symbolic meaning as a symbol of meaning.
Here refers to a token or sObject Field, token does not contain specific information, but some of the information acquired by Field sObject or token.
Schema.SObjectType is sObject token type.
Schema.SObjectField is the type of Field token.
Schema.DescribeSObjectResult is the type of sObject describe.
Schema.DescribeFieldResult Field describe the type of.
Code Example:

Map<String, Schema.SObjectType> map = Schema.getGlobalDescribe();
system.debug(map);

The above operation log output code is

{acceptedeventrelation=AcceptedEventRelation, account=Account, accountchangeevent=AccountChangeEvent, accountcleaninfo=AccountCleanInfo, accountcontactrole=AccountContactRole, accountcontactrolechangeevent=AccountContactRoleChangeEvent, accountfeed=AccountFeed, accounthistory=AccountHistory, accountpartner=AccountPartner, accountshare=AccountShare, ...}

Get one sObject the token can pass through it in two ways:
for example, to obtain a token Account of
⑴.

Schema.SObjectType type = account.sobjectType;
system.debug(type);

The above code is output: the Account
(2).

Account account = new Account();
system.debug(account.getsObjectType());

The output of the above code is the same Account

Guess you like

Origin blog.51cto.com/ssspure/2437954