简体   繁体   中英

How to add data in CalendarRulesType attribute using c# in Dynamics CRM

Can anybody give an example or ref link for how to add data or create a record with CalenderRules type attribute using c# in dynamics crm.

Information about CalenderRules type attribute is displayed in below link.but can't find actually how to add.

https://msdn.microsoft.com/en-in/library/dn817862.aspx#BKMK_Image

From the article you have referenced.

There are no actual attributes that use the CalendarRulesType . When using the early binding style, the code generation tool will create the following two simulated attributes that are not present in the metadata. These attributes actually represent a view of the calendar rules records associated in a one-to-many relationship to the entity instance .

Just like any other relationship, you can use Associate or just use the early/late bound attributes and reference the entity collection:

Early/Late bound:

calendar.CalendarRules = new[]
{
   new CalendarRule()
   {
      Id = calendarRuleId
   }
};

Associate:

 organizationService.Associate(Calendar.EntityLogicalName, calendarId, new Relationship("calendar_calendar_rules"),
                new EntityReferenceCollection(new[]
                {
                    new EntityReference(CalendarRule.EntityLogicalName, calendarRuleId)
                }));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM