441. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:35 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

441.1 Files compared

# Location File Last Modified
1 C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\CS\GeneralProgramming\Queries RetrieveMultipleConditionOperatorsLinq.cs Tue Dec 20 19:51:46 2016 UTC
2 Wed Feb 1 19:56:35 2017 UTC

441.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 0 0
Removed 1 312

441.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

441.4 Active regular expressions

No regular expressions were active.

441.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
3   //        
4   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
5   //        
6   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
7   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
8   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
9   //        
10   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
11   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
12   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
13   //  PARTIC ULAR PURPO SE.        
14   // ======= ========== ========== ========== ========== ========== ========== ==        
15          
16   //<snippet RetrieveMu ltipleCond itionOpera torsLinq>        
17   using Syst em;        
18   using Syst em.Service Model;        
19   using Syst em.Collect ions.Gener ic;        
20   using Syst em.Linq;        
21          
22   // These n amespaces  are found  in the Mic rosoft.Xrm .Sdk.dll a ssembly        
23   // located  in the SD K\bin fold er of the  SDK downlo ad.        
24   using Micr osoft.Xrm. Sdk;        
25   using Micr osoft.Xrm. Sdk.Client ;        
26          
27   namespace  Microsoft. Crm.Sdk.Sa mples        
28   {        
29    /// <summ ary>        
30    /// Demon strates ho w to do us e retrieve  multiple  condition  operators  for all        
31    /// query  types.</s ummary>        
32    /// <rema rks>        
33    /// At ru n-time, yo u will be  given the  option to  delete all  the        
34    /// datab ase record s created  by this pr ogram.</re marks>        
35    public cl ass Retrie veMultiple ConditionO peratorsLi nq        
36    {        
37     #region  Class Leve l Members        
38          
39     private  Guid _acco untId;        
40     private  List<Guid>  _contactI dList = ne w List<Gui d>();        
41     private  Organizati onServiceP roxy _serv iceProxy;        
42     private  IOrganizat ionService  _service;        
43          
44     #endregi on Class L evel Membe rs        
45          
46     #region  How To Sam ple Code        
47     /// <sum mary>        
48     /// This  method fi rst connec ts to the  Organizati on service . Afterwar ds,        
49     /// basi c LINQ que ries are p erformed.        
50     /// </su mmary>        
51     /// <par am name="s erverConfi g">Contain s server c onnection  informatio n.</param>        
52     /// <par am name="p romptforDe lete">When  True, the  user will  be prompt ed to dele te all        
53     /// crea ted entiti es.</param >        
54     public v oid Run(Se rverConnec tion.Confi guration s erverConfi g, bool pr omptforDel ete)        
55     {        
56      try        
57      {        
58          
59       // Con nect to th e Organiza tion servi ce.         
60       // The  using sta tement ass ures that  the servic e proxy wi ll be prop erly dispo sed.        
61       using  (_serviceP roxy = new  Organizat ionService Proxy(serv erConfig.O rganizatio nUri, serv erConfig.H omeRealmUr i,serverCo nfig.Crede ntials, se rverConfig .DeviceCre dentials))        
62       {        
63        // Th is stateme nt is requ ired to en able early -bound typ e support.        
64        _serv iceProxy.E nableProxy Types();        
65          
66        _serv ice = (IOr ganization Service)_s erviceProx y;        
67          
68        Creat eRequiredR ecords();        
69          
70        // Cr eate the S erviceCont ext object  that will  generate        
71        // th e IQueryab le collect ions for L INQ calls.        
72        Servi ceContext  svcContext  =        
73            n ew Service Context(_s ervice);        
74          
75                                      
76        #regi on SQL Que ry Transla ted to LIN Q        
77        // Bu ild the fo llowing SQ L query us ing QueryE xpression:        
78        //        
79        //          SELE CT contact .fullname,  contact.a ddress1_te lephone1        
80        //          FROM  contact        
81        //                   LEFT O UTER JOIN  account        
82        //                            ON conta ct.parentc ustomerid  = account. accountid        
83        //                            AND        
84        //                            account. name = 'Li tware, Inc .'        
85        //          WHER E (contact .address1_ stateorpro vince = 'W A'        
86        //          AND        
87        //                   contac t.address1 _city in ( 'Redmond',  'Bellevue ', 'Kirkla nd', 'Seat tle')        
88        //          AND         
89        //                   contac t.address1 _telephone 1 like '(2 06)%'        
90        //                   OR        
91        //                   contac t.address1 _telephone 1 like '(4 25)%'        
92        //          AND        
93        //                   contac t.emailadd ress1 Not  NULL        
94        //                      )        
95        //<sn ippetRetri eveMultipl eCondition OperatorsL inq1>        
96        var c ontacts =  (from c in  svcContex t.ContactS et        
97                          join a in  svcContex t.AccountS et on c.Pa rentCustom erId.Id eq uals a.Acc ountId        
98                          where (a. Name == "L itware, In c.")        
99                          where (c. Address1_S tateOrProv ince == "W A"        
100                          && (c.Add ress1_Tele phone1.Sta rtsWith("( 206)") ||        
101                              c.Add ress1_Tele phone1.Sta rtsWith("( 425)"))        
102                          && (c.Add ress1_City  == "Redmo nd" ||        
103                              c.Add ress1_City  == "Belle vue" ||        
104                              c.Add ress1_City  == "Kirkl and" ||        
105                              c.Add ress1_City  == "Seatt le")        
106                          && (c.EMa ilAddress1  != null & & c.EMailA ddress1 !=  ""))        
107                          select ne w Contact        
108                          {        
109                           ContactI d = c.Cont actId,        
110                           FirstNam e = c.Firs tName,        
111                           LastName  = c.LastN ame,        
112                           Address1 _Telephone 1 = c.Addr ess1_Telep hone1        
113                          });        
114          
115        // Di splay the  results.        
116        Conso le.WriteLi ne("List a ll contact s matching  specified  parameter s");        
117        Conso le.WriteLi ne("====== ========== ========== ========== ========== =");        
118        forea ch (Contac t contact  in contact s)        
119        {        
120         Cons ole.WriteL ine("Conta ct ID: {0} ", contact .Id);        
121         Cons ole.WriteL ine("Conta ct Name: { 0}", conta ct.FullNam e);        
122         Cons ole.WriteL ine("Conta ct Phone:  {0}", cont act.Addres s1_Telepho ne1);        
123        }        
124        Conso le.WriteLi ne("<End o f Listing> ");        
125        Conso le.WriteLi ne();        
126        #endr egion        
127        //</s nippetRetr ieveMultip leConditio nOperators Linq1>        
128          
129        //OUT PUT:        
130        //Lis t all cont acts match ing specif ied parame ters        
131        //=== ========== ========== ========== ========== ====        
132        //Con tact ID: a 263e139-63 a3-e011-ae a3-00155db a3818        
133        //Con tact Name:        
134        //Con tact Phone : (206)555 -5555        
135        //Con tact ID: a 463e139-63 a3-e011-ae a3-00155db a3818        
136        //Con tact Name:        
137        //Con tact Phone : (425)555 -5555        
138        //<En d of Listi ng>        
139          
140        Delet eRequiredR ecords(pro mptforDele te);        
141       }        
142          
143      }        
144          
145      // Catc h any serv ice fault  exceptions  that Micr osoft Dyna mics CRM t hrows.        
146      catch ( FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault>)        
147      {        
148       // You  can handl e an excep tion here  or pass it  back to t he calling  method.        
149       throw;        
150      }        
151     }        
152          
153     /// <sum mary>        
154     /// Crea tes any en tity recor ds that th is sample  requires.        
155     /// </su mmary>        
156     public v oid Create RequiredRe cords()        
157     {        
158      // Crea te an acco unt.        
159      Account  account =  new Accou nt        
160      {        
161       Name =  "Litware,  Inc."        
162      };        
163      _accoun tId = _ser vice.Creat e(account) ;        
164          
165      // Crea te the 2 c ontacts.        
166      Contact  contact =  new Conta ct()        
167      {        
168       FirstN ame = "Ben ",        
169       LastNa me = "Andr ews",        
170       EMailA ddress1 =  "sample@ex ample.com" ,        
171       Addres s1_City =  "Redmond",        
172       Addres s1_StateOr Province =  "WA",        
173       Addres s1_Telepho ne1 = "(20 6)555-5555 ",        
174       Parent CustomerId  = new Ent ityReferen ce        
175       {        
176        Id =  _accountId ,        
177        Logic alName = a ccount.Log icalName        
178       }        
179      };        
180      _contac tIdList.Ad d(_service .Create(co ntact));        
181          
182      contact  = new Con tact()        
183      {        
184       FirstN ame = "Col in",        
185       LastNa me = "Wilc ox",        
186       EMailA ddress1 =  "sample@ex ample.com" ,        
187       Addres s1_City =  "Bellevue" ,        
188       Addres s1_StateOr Province =  "WA",        
189       Addres s1_Telepho ne1 = "(42 5)555-5555 ",        
190       Parent CustomerId  = new Ent ityReferen ce        
191       {        
192        Id =  _accountId ,        
193        Logic alName = a ccount.Log icalName        
194       }        
195      };        
196      _contac tIdList.Ad d(_service .Create(co ntact));        
197     }        
198          
199     /// <sum mary>        
200     /// Dele tes any en tity recor ds that we re created  for this  sample.        
201     /// <par am name="p rompt">Ind icates whe ther to pr ompt the u ser         
202     /// to d elete the  records cr eated in t his sample .</param>        
203     /// </su mmary>        
204     public v oid Delete RequiredRe cords(bool  prompt)        
205     {        
206      bool to BeDeleted  = true;        
207          
208      if (pro mpt)        
209      {        
210       // Ask  the user  if the cre ated entit ies should  be delete d.        
211       Consol e.Write("\ nDo you wa nt these e ntity reco rds delete d? (y/n) [ y]: ");        
212       String  answer =  Console.Re adLine();        
213       if (an swer.Start sWith("y")  ||        
214           an swer.Start sWith("Y")  ||        
215           an swer == St ring.Empty )        
216       {        
217        toBeD eleted = t rue;        
218       }        
219       else        
220       {        
221        toBeD eleted = f alse;        
222       }        
223      }        
224          
225      if (toB eDeleted)        
226      {        
227       // Del ete all re cords crea ted in thi s sample.        
228       foreac h (Guid co ntactId in  _contactI dList)        
229       {        
230        _serv ice.Delete (Contact.E ntityLogic alName, co ntactId);        
231       }        
232          
233       _servi ce.Delete( Account.En tityLogica lName, _ac countId);        
234          
235       Consol e.WriteLin e("Entity  record(s)  have been  deleted.") ;        
236      }        
237     }        
238          
239     #endregi on How To  Sample Cod e        
240          
241     #region  Main metho d        
242          
243     /// <sum mary>        
244     /// Stan dard Main( ) method u sed by mos t SDK samp les.        
245     /// </su mmary>        
246     /// <par am name="a rgs"></par am>        
247     static p ublic void  Main(stri ng[] args)        
248     {        
249      try        
250      {        
251       // Obt ain the ta rget organ ization's  Web addres s and clie nt logon         
252       // cre dentials f rom the us er.        
253       Server Connection  serverCon nect = new  ServerCon nection();        
254       Server Connection .Configura tion confi g = server Connect.Ge tServerCon figuration ();        
255          
256       Retrie veMultiple ConditionO peratorsLi nq app = n ew Retriev eMultipleC onditionOp eratorsLin q();        
257       app.Ru n(config,  true);        
258      }        
259      catch ( FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> e x)        
260      {        
261       Consol e.WriteLin e("The app lication t erminated  with an er ror.");        
262       Consol e.WriteLin e("Timesta mp: {0}",  ex.Detail. Timestamp) ;        
263       Consol e.WriteLin e("Code: { 0}", ex.De tail.Error Code);        
264       Consol e.WriteLin e("Message : {0}", ex .Detail.Me ssage);        
265       Consol e.WriteLin e("Plugin  Trace: {0} ", ex.Deta il.TraceTe xt);        
266       Consol e.WriteLin e("Inner F ault: {0}" ,        
267           nu ll == ex.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault");        
268      }        
269      catch ( System.Tim eoutExcept ion ex)        
270      {        
271       Consol e.WriteLin e("The app lication t erminated  with an er ror.");        
272       Consol e.WriteLin e("Message : {0}", ex .Message);        
273       Consol e.WriteLin e("Stack T race: {0}" , ex.Stack Trace);        
274       Consol e.WriteLin e("Inner F ault: {0}" ,        
275           nu ll == ex.I nnerExcept ion.Messag e ? "No In ner Fault"  : ex.Inne rException .Message);        
276      }        
277      catch ( System.Exc eption ex)        
278      {        
279       Consol e.WriteLin e("The app lication t erminated  with an er ror.");        
280       Consol e.WriteLin e(ex.Messa ge);        
281          
282       // Dis play the d etails of  the inner  exception.        
283       if (ex .InnerExce ption != n ull)        
284       {        
285        Conso le.WriteLi ne(ex.Inne rException .Message);        
286          
287        Fault Exception< Microsoft. Xrm.Sdk.Or ganization ServiceFau lt> fe = e x.InnerExc eption        
288            a s FaultExc eption<Mic rosoft.Xrm .Sdk.Organ izationSer viceFault> ;        
289        if (f e != null)        
290        {        
291         Cons ole.WriteL ine("Times tamp: {0}" , fe.Detai l.Timestam p);        
292         Cons ole.WriteL ine("Code:  {0}", fe. Detail.Err orCode);        
293         Cons ole.WriteL ine("Messa ge: {0}",  fe.Detail. Message);        
294         Cons ole.WriteL ine("Plugi n Trace: { 0}", fe.De tail.Trace Text);        
295         Cons ole.WriteL ine("Inner  Fault: {0 }",        
296              null == fe .Detail.In nerFault ?  "No Inner  Fault" :  "Has Inner  Fault");        
297        }        
298       }        
299      }        
300      // Addi tional exc eptions to  catch: Se curityToke nValidatio nException , ExpiredS ecurityTok enExceptio n,        
301      // Secu rityAccess DeniedExce ption, Mes sageSecuri tyExceptio n, and Sec urityNegot iationExce ption.        
302          
303      finally        
304      {        
305       Consol e.WriteLin e("Press < Enter> to  exit.");        
306       Consol e.ReadLine ();        
307      }        
308     }        
309     #endregi on Main me thod        
310    }        
311   }        
312   //</snippe tRetrieveM ultipleCon ditionOper atorsLinq>