Microsoft Dynamics CRM 2011 ve Microsoft
Dynamics CRM Online'da programlama modeli .NET'in temel türlerini kullanacak
şekilde değiştirildi.
Bu tabloda beni en çok şaşırtan ise
Customer, Lookup, Owner nesnelerinin artık EntityReference türünden sadece bir
değer almaları. CRM'i yeni öğrenler için işler gerçekten kolaylaştırılmış.
Artık kod yazarken CRM ile başlayan nesnelerimiz yok.
Aşağıdaki tablo bize Microsoft Dynamics
CRM 4.0 ile CRM 2011, 2013 ve 2015 arasındaki tür dönüşümünü göstermektedir.
Özellik Adı
|
Microsoft Dynamics CRM 2011, 2013, 2015 Türü
|
Microsoft Dynamics CRM 4.0 Türü
|
AttributeTypeCode.Boolean
|
bool ya da System.Boolean
|
CrmBoolean
|
AttributeType.CalendarRules
|
EntityCollection
|
DynamicEntity[] or calendarrule[]
|
AttributeType.Customer
|
EntityReference
|
Customer
|
AttributeType.DateTime
|
System.DateTime
|
CrmDateTime
|
AttributeType.Decimal
|
decimal ya da System.Decimal
|
CrmDecimal
|
AttributeType.Double
|
double ya da System.Double
|
CrmFloat
|
AttributeType.Integer
|
int ya da System.Integer
|
CrmNumber
|
AttributeType.Internal
|
System.Object
Kayıtlarda Kullanılmaz
|
Kayıtlarda Kullanılmaz.
|
AttributeType.Lookup
|
EntityReference
|
Lookup
|
AttributeType.Memo
|
string ya da System.String
|
System.String
|
AttributeType.Money
|
Money
|
CrmMoney
|
AttributeType.Owner
|
EntityReference
|
Owner
|
AttributeType.PartyList
|
EntityCollection or ActivityParty[]
|
activityparty[] or DynamicEntity []
|
AttributeType.Picklist
|
OptionSetValue
|
Picklist
|
AttributeType.PrimaryKey
|
System.Guid
|
Key
|
AttributeType.String
|
System.String
|
System.String
|
AttributeType.State
|
OptionSetValue yada oluşturulan
enumeration kullanılmalı
|
EntityNameStateInfo
|
AttributeType.Status
|
OptionSetValue ya da int
|
Status
|
AttributeType.Uniqueidentifier
|
System.Guid
|
UniqueIdentifier
|
AttributeType.Virtual
|
System.Object
Kayıtlarda Kullanılmaz
|
Kayıtlarda Kullanılmaz
|
Eski Tür
|
Yeni Tür
|
CrmAttributeType Class
(MetadataService)
|
Microsoft.Xrm.Sdk.Metadata.AttributeTypeCode
|
Moniker Class (CrmService)
|
Microsoft.Xrm.Sdk.EntityReference
|
SecurityPrincipal Class (CrmService)
|
Microsoft.Xrm.Sdk.EntityReference
|
|
|
|
|
|
OptionSetValue’a değer atamak için ilk
önce OptionSetValue türünden bir nesne oluşturmanız gerekmektedir. Burada dikkat çekmek istediğim konu ise eğer
state alanı ile çalışacaksanız (yani firma için aktif/pasif, teklif için
açık/kazanıldı/kaybedildi gibi) early-bound sınıflarda bunlar için mutlaka bir
enumaration oluşturulmakta. Ama late bound sınıflarda bu durumu programcı
yönetmektedir.
Örnek olarak adres üzerindeki bir
optionset alana değer atama aşağıdaki şekilde olmaktadır;
OptionSetValue osv = new OptionSetValue(1);
contact.Attributes["address1_freighttermscode"] = osv;
CRM sisteminde iki entity’yi birbirine
bağlamak için lookup nesnesini kullanmak zorundayız. Lookup’lar üzerinde
programatik işlem yapabilmek için EntityReference nesnesini kullanmaktayız. Bu
nesneye Lookup alana reference vermek istemiz nesnenin türü ve Id’sini vermemiz
gerekmektedir.
Aşağıdaki örnekte parentAccountId atama
yapılacak nesnenin guid cinsinden Id’si olmalı;
EntityReference parentaccountid = new EntityReference("account", parentAccountId));
accountEntity.Attributes["parentaccountid"] = parentaccountid;
ioService.Update(accountEntity);
CRM 4.0’dan farklı olarak .Net Type
türleri kullanıldığı için null değer atama işlemi artık sadece alana değer
vermekten ibaret oldu. İşte birkaç örnek;
EntityAdi.IndustryCode = null;
EntityAdi.AccountId = Guid.Empty;
EntityAdi.AccountNumber ="";
EntityAdi.Address1_Country = String.Empty;