To write back database you need to prepare Application Definition File (ADF) and add Some Method of type "GenericInvoker" and for Retreive data you need to have a Method of type "Finder".Here is sample of Finder Method :
<Method Name="SimpleSearch">
<FilterDescriptors>
<FilterDescriptor Type="Comparison" Name="SearchDescriptor" DefaultDisplayName="آرگومان جستجو">
<Properties>
<Property Name="Comparator" Type="System.String">Equals</Property>
</Properties>
</FilterDescriptor>
</FilterDescriptors>
<Parameters>
<Parameter Direction="In" Name="searchArgument">
<TypeDescriptor TypeName="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" AssociatedFilter="SearchDescriptor" Name="searchArgument" />
</Parameter>
<Parameter Direction="Return" Name="Return">
<TypeDescriptor TypeName="BDC.PhonebookEntry[],PhoneBookLobSystem" IsCollection="true" Name="Return">
<TypeDescriptors>
<TypeDescriptor TypeName="BDC.PhonebookEntry,PhoneBookLobSystem" Name="Item">
<TypeDescriptors>
<TypeDescriptor TypeName="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="PhoneNo" />
<TypeDescriptor TypeName="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Empno" />
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</Parameter>
</Parameters>
<MethodInstances>
<MethodInstance Type="Finder" ReturnParameterName="Return" ReturnTypeDescriptorName="Return" ReturnTypeDescriptorLevel="0" Name="PhoneBook_Finder_Instance" />
</MethodInstances>
</Method>
There are some important notes in ADF:
· You must define Return parameter as last parameter
· You can not pass null values to methods, in our case we used webservice the other alternative is to use stored procedure
To execute Methods you can use a code like the bellow example it is about filling controls from database:
NamedLobSystemDictionary lobSystems = ApplicationRegistry.GetLobSystems();
LobSystem lobSystem = lobSystems[lobSystemName];
NamedLobSystemInstanceDictionary lobInstances = lobSystem.GetLobSystemInstances();
LobSystemInstance lobInstance = lobInstances[lobSystemInstanceName];
Entity entityObject = lobInstance.GetEntities()[entityName];
NamedMethodInstanceDictionary methodInstances = entityObject.GetMethodInstances();
MethodInstance methInstance = methodInstances[selectmethodInstanceName];
Object[] methodArgs = methInstance.GetMethod().CreateDefaultParameterInstances(methInstance);
Object[] methodArgs = methInstance.GetMethod().CreateDefaultParameterInstances(methInstance);
methodArgs[0] = ObjectID;
IEntityInstanceEnumerator c = (IEntityInstanceEnumerator)entityObject.Execute(methInstance, lobInstance, ref methodArgs);
while (c.MoveNext())
{
IEntityInstance IE = c.Current;
//You can Populate Controls here
(IE["YouFieldName"] }