File: ProductModel.cs

package info (click to toggle)
mono-reference-assemblies 3.12.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 604,240 kB
  • ctags: 625,505
  • sloc: cs: 3,967,741; xml: 2,793,081; ansic: 418,042; java: 60,435; sh: 14,833; makefile: 11,576; sql: 7,956; perl: 1,467; cpp: 1,446; yacc: 1,203; python: 598; asm: 422; sed: 16; php: 1
file content (695 lines) | stat: -rw-r--r-- 26,813 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

namespace System.Data.Entity.Query
{
    public static class ProductModel
    {
        public static readonly string ssdl =
            @"<?xml version=""1.0"" encoding=""utf-8""?>
<Schema Namespace=""ProductStore"" Alias=""Self"" Provider=""System.Data.SqlClient"" ProviderManifestToken=""2008"" xmlns=""http://schemas.microsoft.com/ado/2009/11/edm/ssdl"">
  <EntityContainer Name=""ProductContainer_Store"">
    <EntitySet Name=""Products"" EntityType=""Self.Product"" Schema=""dbo"" Table=""Products"" />
    <EntitySet Name=""Customers"" EntityType=""Self.Customer"" Schema=""dbo"" Table=""Customers"" />
  </EntityContainer>
  <EntityType Name=""Product"">
    <Key>
      <PropertyRef Name=""ProductID"" />
    </Key>
    <Property Name=""ProductID"" Type=""int"" Nullable=""false"" />
    <Property Name=""ProductName"" Type=""nvarchar"" MaxLength=""40"" />
    <Property Name=""ReorderLevel"" Type=""smallint"" />
    <Property Name=""Discontinued"" Type=""bit"" />
  </EntityType>
  <EntityType Name=""Customer"">
    <Key>
      <PropertyRef Name=""CustomerID"" />
    </Key>
    <Property Name=""CustomerID"" Type=""nvarchar"" Nullable=""false"" MaxLength=""5""/>
    <Property Name=""HomeAddress"" Type=""nvarchar"" MaxLength=""60"" />
    <Property Name=""City"" Type=""nvarchar"" MaxLength=""15"" />
    <Property Name=""Region"" Type=""nvarchar"" MaxLength=""15"" />
    <Property Name=""PostalCode"" Type=""nvarchar"" MaxLength=""10"" />
    <Property Name=""Country"" Type=""nvarchar"" MaxLength=""15"" />
    <Property Name=""Phone"" Type=""nvarchar"" MaxLength=""24"" />
    <Property Name=""Fax"" Type=""nvarchar"" MaxLength=""24"" />
  </EntityType>
</Schema>";

        public static readonly string msl =
            @"<?xml version=""1.0"" encoding=""utf-8""?>
<Mapping xmlns=""http://schemas.microsoft.com/ado/2009/11/mapping/cs"" Space=""C-S"">
  <EntityContainerMapping CdmEntityContainer=""ProductContainer"" StorageEntityContainer=""ProductContainer_Store"">
    <EntitySetMapping Name=""Products"">
      <EntityTypeMapping TypeName=""ProductModel.Product"">
        <MappingFragment StoreEntitySet=""Products"">
          <ScalarProperty Name=""ProductID"" ColumnName=""ProductID"" />
          <ScalarProperty Name=""ProductName"" ColumnName=""ProductName"" />
          <ScalarProperty Name=""ReorderLevel"" ColumnName=""ReorderLevel"" />
          <Condition Value=""false"" ColumnName=""Discontinued"" />
        </MappingFragment>
      </EntityTypeMapping>
      <EntityTypeMapping TypeName=""ProductModel.DiscontinuedProduct"">
        <MappingFragment StoreEntitySet=""Products"">
          <ScalarProperty Name=""ProductID"" ColumnName=""ProductID"" />
          <ScalarProperty Name=""ProductName"" ColumnName=""ProductName"" />
          <ScalarProperty Name=""ReorderLevel"" ColumnName=""ReorderLevel"" />
          <Condition Value=""true"" ColumnName=""Discontinued"" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
    <EntitySetMapping Name=""Customers"">
      <EntityTypeMapping TypeName=""ProductModel.Customer"">
        <MappingFragment StoreEntitySet=""Customers"">
          <ScalarProperty Name=""CustomerID"" ColumnName=""CustomerID"" />
          <ComplexProperty Name=""Address"" TypeName=""ProductModel.Address"">
            <ScalarProperty Name=""HomeAddress"" ColumnName=""HomeAddress"" />
            <ScalarProperty Name=""City"" ColumnName=""City"" />
            <ScalarProperty Name=""Region"" ColumnName=""Region"" />
            <ScalarProperty Name=""PostalCode"" ColumnName=""PostalCode"" />
            <ScalarProperty Name=""Country"" ColumnName=""Country"" />
          </ComplexProperty>
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
</EntityContainerMapping>
</Mapping>";

        private static readonly string csdlTemplate =
            @"<?xml version=""1.0"" encoding=""utf-8""?>
<Schema Namespace=""ProductModel"" Alias=""Self"" xmlns=""http://schemas.microsoft.com/ado/2009/11/edm"">
  <EntityContainer Name=""ProductContainer"">
    <EntitySet Name=""Products"" EntityType=""Self.Product"" />
    <EntitySet Name=""Customers"" EntityType=""Self.Customer"" />
  </EntityContainer>
  <EntityType Name=""Product"">
    <Key>
      <PropertyRef Name=""ProductID"" />
    </Key>
    <Property Name=""ProductID"" Type=""Int32"" Nullable=""false"" />
    <Property Name=""ProductName"" Type=""String"" MaxLength=""40"" />
    <Property Name=""ReorderLevel"" Type=""Int16"" />
  </EntityType>
  <EntityType Name=""DiscontinuedProduct"" BaseType=""Self.Product"" />
  <EntityType Name=""Customer"">
    <Key>
      <PropertyRef Name=""CustomerID"" />
    </Key>
    <Property Name=""CustomerID"" Type=""String"" Nullable=""false"" />
    <Property Name=""Address"" Type=""Self.Address"" Nullable=""false"" />
  </EntityType>
  <ComplexType Name=""Address"">
    <Property Name=""HomeAddress"" Type=""String"" />
    <Property Name=""City"" Type=""String"" />
    <Property Name=""Region"" Type=""String"" />
    <Property Name=""PostalCode"" Type=""String"" />
    <Property Name=""Country"" Type=""String"" />
  </ComplexType>
  <Function Name=""F_CountProducts"" ReturnType=""Int32"">
    <Parameter Name=""products"" Type=""Collection(Self.Product)""/>
    <DefiningExpression>
      count(select value 1 from products)
    </DefiningExpression>
  </Function>
  {0}
</Schema>";

        private static readonly string modelDefinedFunctions =
            @" <Function Name=""F_NoBody"" ReturnType=""Int32"" />
  <Function Name=""F_A"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      F_B() - F_C()
    </DefiningExpression>
  </Function>
  <!-- positive: test inline functions in the function definition -->
  <Function Name=""F_B"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      function F_B() as (1)
      function F_A() as (F_B())
      F_A()
    </DefiningExpression>
  </Function>
  <!-- positive: test backward references -->
  <Function Name=""F_C"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      F_B() + 2
    </DefiningExpression>
  </Function>
  <!-- negative: test self reference -->
  <Function Name=""F_D"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      F_D() + 1
    </DefiningExpression>
  </Function>
  <!-- negative: test recursion thru another function -->
  <Function Name=""F_E"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      F_F() - F_C()
    </DefiningExpression>
  </Function>
  <!-- negative: test recursion thru another function -->
  <Function Name=""F_F"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      F_E() + 1
    </DefiningExpression>
  </Function>
  <!-- negative: when used with a query containing an inline function F_H() should still fail because 
       model functions can not reference query functions-->
  <Function Name=""F_G"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      F_H() + 1
    </DefiningExpression>
  </Function>
  <!-- negative: function definition has different type than the declaration -->
  <Function Name=""F_I"" ReturnType=""Int32"">
    <Parameter Name=""p"" Type=""Int64""/>
    <DefiningExpression>
      CAST(p AS Int16)
    </DefiningExpression>
  </Function>
  <!-- positive: identity function -->
  <Function Name=""F_J"" ReturnType=""Int32"">
    <Parameter Name=""p"" Type=""Int32""/>
    <DefiningExpression>
      p
    </DefiningExpression>
  </Function>
  <!-- positive: function returns a scalar type -->
  <Function Name=""F_Ret_ST"" ReturnType=""Int32"">
    <DefiningExpression>
      using ProductModel;
      Count(select value 3 from ProductContainer.Products as p)
    </DefiningExpression>
  </Function>
  <!-- positive: function returns a collection of scalars type -->
  <Function Name=""F_Ret_ColST"" ReturnType=""Collection(Int32)"">
    <DefiningExpression>
      using ProductModel;
      select value p.ProductID - 3 from ProductContainer.Products as p
    </DefiningExpression>
  </Function>
  <!-- positive: function returns an entity type -->
  <Function Name=""F_Ret_ET"" ReturnType=""Self.Product"">
    <DefiningExpression>
      using ProductModel;
      anyelement(select value top(1) p from ProductContainer.Products as p order by p.ProductID)
    </DefiningExpression>
  </Function>
  <!-- positive: function returns a collection of entities type -->
  <Function Name=""F_Ret_ColET"" ReturnType=""Collection(Self.Product)"">
    <DefiningExpression>
      using ProductModel;
      select value top(5) p from ProductContainer.Products as p order by p.ProductID
    </DefiningExpression>
  </Function>
  <!-- positive: function takes an entity type returns an entity type -->
  <Function Name=""F_In_ET_Ret_BaseET"" ReturnType=""Self.Product"">
    <Parameter Name=""Prod"" Type=""Self.Product""/>
    <DefiningExpression>
      using ProductModel;
      Prod
    </DefiningExpression>
  </Function>
  <!-- positive: function takes an entity type returns an entity type -->
  <Function Name=""F_In_ET_Ret_DerivedET"" ReturnType=""Self.DiscontinuedProduct"">
    <Parameter Name=""Prod"" Type=""Self.DiscontinuedProduct""/>
    <DefiningExpression>
      using ProductModel;
      Prod
    </DefiningExpression>
  </Function>
  <!-- positive: function returns a complex type -->
  <Function Name=""F_Ret_CT"" ReturnType=""Self.Address"">
    <DefiningExpression>
      using ProductModel;
      anyelement(select value top(1) c.Address from ProductContainer.Customers as c order by c.CustomerID)
    </DefiningExpression>
  </Function>
  <!-- positive: function returns a collection of complex type elements -->
  <Function Name=""F_Ret_ColCT"" ReturnType=""Collection(Self.Address)"">
    <DefiningExpression>
      using ProductModel;
      select value top(5) c.Address from ProductContainer.Customers as c order by c.CustomerID
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of scalars returns a collection of entity type -->
  <Function Name=""F_In_ColST_Ret_ColET"" ReturnType=""Collection(Self.Customer)"">
    <Parameter Name=""IDs"" Type=""Collection(String)""/>
    <DefiningExpression>
      using ProductModel;
      select value c from ProductContainer.Customers as c where c.CustomerID in IDs
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of entities returns a collection of complex type -->
  <Function Name=""F_In_ColET_Ret_ColCT"" ReturnType=""Collection(Self.Address)"">
    <Parameter Name=""pCustomers"" Type=""Collection(Self.Customer)""/>
    <DefiningExpression>
      using ProductModel;
      select value c.Address from pCustomers as c where c.CustomerID = 'BONAP'
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of complex type elements returns a scalar -->
  <Function Name=""F_In_ColCT_Ret_ST"" ReturnType=""String"">
    <Parameter Name=""pAddresses"" Type=""Collection(Self.Address)""/>
    <DefiningExpression>
      using ProductModel;
      Min(select value a.City from pAddresses as a where a.Country = 'Mexico')
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of complex type elements returns a collection of scalar types -->
  <Function Name=""F_In_ColCT_Ret_ColST"" ReturnType=""Collection(String)"">
    <Parameter Name=""pAddresses"" Type=""Collection(Self.Address)""/>
    <DefiningExpression>
      using ProductModel;
      select value a.City from pAddresses as a where a.Country = 'Mexico'
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of Customers entities returns a collection of entities -->
  <Function Name=""F_In_ColET_Ret_ColET"" ReturnType=""Collection(Self.Customer)"">
    <Parameter Name=""pCustomers"" Type=""Collection(Self.Customer)""/>
    <DefiningExpression>
      using ProductModel;
      select value c from pCustomers as c where c.Address.Country = 'Mexico'
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of complex type elements returns a collection of complex type elements -->
  <Function Name=""F_In_ColCT_Ret_ColCT"" ReturnType=""Collection(Self.Address)"">
    <Parameter Name=""pAddresses"" Type=""Collection(Self.Address)""/>
    <DefiningExpression>
      using ProductModel;
      select value p from pAddresses as p where p.Country = 'Mexico'
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of scalars returns a collection of scalars -->
  <Function Name=""F_In_ColST_Ret_ColST"" ReturnType=""Collection(String)"">
    <Parameter Name=""pStrings"" Type=""Collection(String)""/>
    <DefiningExpression>
      using ProductModel;
      pStrings intersect {'a', 'b', 'c'}
    </DefiningExpression>
  </Function>
  <!-- positive: function takes collection of scalars returns a collection of scalars -->
  <Function Name=""F_In_ColST_Ret_NonEmptyColST"" ReturnType=""Collection(String)"">
    <Parameter Name=""pStrings"" Type=""Collection(String)""/>
    <DefiningExpression>
      using ProductModel;
      pStrings
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a row returns a row-->
  <Function Name=""F_In_RT_Ret_RT"">
    <ReturnType>
      <RowType>
        <Property Name=""X"" Type=""Int32""/>
        <Property Name=""Y"" Type=""String""/>
        <Property Name=""AA"" Type=""Self.Address""/>
      </RowType>
    </ReturnType>
    <Parameter Name=""pRow"">
      <RowType>
        <Property Name=""Cust"" Type=""Self.Customer""/>
      </RowType>
    </Parameter>
    <DefiningExpression>
      using ProductModel;
      row(Length(pRow.Cust.CustomerID) as X, pRow.Cust.Address.City as Y, pRow.Cust.Address as AA)
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a scalar returns a row-->
  <Function Name=""F_In_ST_Ret_RT"">
    <ReturnType>
      <RowType>
        <Property Name=""X"" Type=""Int32""/>
        <Property Name=""Y"" Type=""String""/>
      </RowType>
    </ReturnType>
    <Parameter Name=""p"" Type=""Int32""/>
    <DefiningExpression>
      using ProductModel;
      row(p + 3 as X, 'alltypes' as Y)
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a row(Int, String) returns a scalar-->
  <Function Name=""F_In_RT_Int_String_Ret_ST"" ReturnType=""Int32"">
    <Parameter Name=""pRow"">
      <RowType>
        <Property Name=""X"" Type=""Int32""/>
        <Property Name=""Y"" Type=""String""/>
      </RowType>
    </Parameter>
    <DefiningExpression>
      using ProductModel;
      pRow.X
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a row(String, Int) returns a scalar-->
  <Function Name=""F_In_RT_String_Int_Ret_ST"" ReturnType=""Int32"">
    <Parameter Name=""pRow"">
      <RowType>
        <Property Name=""X"" Type=""String""/>
        <Property Name=""Y"" Type=""Int32""/>
      </RowType>
    </Parameter>
    <DefiningExpression>
      using ProductModel;
      pRow.Y+3
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a collection of rows returns a collection of rows -->
  <Function Name=""F_In_ColRT_Ret_ColRT"">
    <ReturnType>
      <CollectionType>
        <RowType>
          <Property Name=""X"" Type=""Int32""/>
          <Property Name=""Y"" Type=""String""/>
          <Property Name=""AA"" Type=""Self.Address""/>
        </RowType>
      </CollectionType>
    </ReturnType>
    <Parameter Name=""pRows"">
      <CollectionType>
        <RowType>
          <Property Name=""Cust"" Type=""Self.Customer""/>
        </RowType>
      </CollectionType>
    </Parameter>
    <DefiningExpression>
      using ProductModel;
      select LENGTH(row.Cust.CustomerID) as X, row.Cust.Address.City as Y, row.Cust.Address as AA
      from pRows as row
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a Entity Type returns a reference -->
  <Function Name=""F_In_ET_Ret_RefET"">
    <ReturnType>
      <ReferenceType Type=""Self.Product""/>
    </ReturnType>
    <Parameter Name=""productArg"" Type=""Self.Product""/>
    <DefiningExpression>
      using ProductModel;
      REF(productArg)
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a Entity Type returns a reference -->
  <Function Name=""F_In_ET_Ret_RefET"">
    <ReturnType>
      <ReferenceType Type=""Self.Customer""/>
    </ReturnType>
    <Parameter Name=""custArg"" Type=""Self.Customer""/>
    <DefiningExpression>
      using ProductModel;
      REF(custArg)
    </DefiningExpression>
  </Function>
  <!-- positive: function takes a collection of references returns a collection of references -->
  <Function Name=""F_In_ColRefET_Ret_ColRefET"">
    <ReturnType>
      <CollectionType>
        <ReferenceType Type=""Self.Customer""/>
      </CollectionType>
    </ReturnType>
    <Parameter Name=""customerRefs"">
      <CollectionType>
        <ReferenceType Type=""Self.Customer""/>
      </CollectionType>
    </Parameter>
    <DefiningExpression>
      using ProductModel;
      select value r from customerRefs as r
    </DefiningExpression>
  </Function>
  <!-- positive: make sure that row field names are ignored during function resolution and type comparisons within the function definition-->
  <Function Name=""F_RowFieldNamessIgnored"">
    <ReturnType>
      <CollectionType>
        <RowType>
          <Property Name=""A"" Type=""Int32""/>
          <Property Name=""B"" Type=""String""/>
        </RowType>
      </CollectionType>
    </ReturnType>
    <Parameter Name=""pRows"">
      <CollectionType>
        <RowType>
          <Property Name=""E"" Type=""Int32""/>
          <Property Name=""F"" Type=""String""/>
        </RowType>
      </CollectionType>
    </Parameter>
    <DefiningExpression>
      select
      r.E + 1 as k,
      r.F + '1' as l
      from pRows as r
      where
      r.E = 1 and
      r.F = '1'
    </DefiningExpression>
  </Function>
  <!-- overload resolution: primitive promotion/ranking -->
  <Function Name=""F_In_Number"" ReturnType=""String"">
    <Parameter Name=""p"" Type=""Int16""/>
    <DefiningExpression>
      '16'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Number"" ReturnType=""String"">
    <Parameter Name=""p"" Type=""Int32""/>
    <DefiningExpression>
      '32'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Number"" ReturnType=""String"">
    <Parameter Name=""p"" Type=""Decimal""/>
    <DefiningExpression>
      'Decimal'
    </DefiningExpression>
  </Function>
  <!--  overload resolution: Primitive types promotion/ranking -->
  <Function Name=""F_In_ST_1"" ReturnType=""Int32"">
    <Parameter Name=""p1"" Type=""Int16""/>
    <Parameter Name=""p2"" Type=""Single""/>
    <DefiningExpression>
      1
    </DefiningExpression>
  </Function>
  <!--  overload resolution: Primitive types promotion/ranking -->
  <Function Name=""F_In_ST_1"" ReturnType=""Int32"">
    <Parameter Name=""p1"" Type=""Int64""/>
    <Parameter Name=""p2"" Type=""Int64""/>
    <DefiningExpression>
      2
    </DefiningExpression>
  </Function>
  <!--  overload resolution: Primitive types promotion/ranking -->
  <Function Name=""F_In_ST_1"" ReturnType=""Int32"">
    <Parameter Name=""p1"" Type=""Single""/>
    <Parameter Name=""p2"" Type=""Int16""/>
    <DefiningExpression>
      3
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_ST_2"" ReturnType=""Int32"">
    <Parameter Name=""p1"" Type=""Byte""/>
    <Parameter Name=""p2"" Type=""Int64""/>
    <DefiningExpression>
      1
    </DefiningExpression>
  </Function>
  <!--  overload resolution: Primitive types promotion/ranking -->
  <Function Name=""F_In_ST_2"" ReturnType=""Int32"">
    <Parameter Name=""p1"" Type=""Int32""/>
    <Parameter Name=""p2"" Type=""Double""/>
    <DefiningExpression>
      2
    </DefiningExpression>
  </Function>
  <!-- overload resolution: entity_inheritance promotion/ranking -->
  <Function Name=""F_In_Entity"" ReturnType=""String"">
    <Parameter Name=""p"" Type=""Self.Product""/>
    <DefiningExpression>
      'Product'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Entity"" ReturnType=""String"">
    <Parameter Name=""p"" Type=""Self.DiscontinuedProduct""/>
    <DefiningExpression>
      'DiscontinuedProduct'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Entity2"" ReturnType=""String"">
    <Parameter Name=""p"" Type=""Self.Product""/>
    <DefiningExpression>
      'Product'
    </DefiningExpression>
  </Function>
  <!-- overload resolution: primitive/entity_inheritance promotion/ranking -->
  <Function Name=""F_In_ProdNumber"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Self.Product""/>
    <Parameter Name=""p2"" Type=""Int32""/>
    <DefiningExpression>
      'Prod-32'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_ProdNumber"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Self.DiscontinuedProduct""/>
    <Parameter Name=""p2"" Type=""Int16""/>
    <DefiningExpression>
      'DiscProd-16'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_ProdNumber2"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Self.DiscontinuedProduct""/>
    <Parameter Name=""p2"" Type=""Decimal""/>
    <DefiningExpression>
      'DiscProd-Decimal'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_ProdNumber2"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Self.Product""/>
    <Parameter Name=""p2"" Type=""Int32""/>
    <DefiningExpression>
      'Prod-32'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_ProdNumber3"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Self.Product""/>
    <Parameter Name=""p2"" Type=""Int32""/>
    <DefiningExpression>
      'Prod-32'
    </DefiningExpression>
  </Function>
  <!-- overload resolution: ref/entity_inheritance promotion/ranking -->
  <Function Name=""F_In_Ref"" ReturnType=""String"">
    <Parameter Name=""p"">
      <ReferenceType Type=""Self.Product""/>
    </Parameter>
    <DefiningExpression>
      'Ref(Product)'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Ref"" ReturnType=""String"">
    <Parameter Name=""p"">
      <ReferenceType Type=""Self.DiscontinuedProduct""/>
    </Parameter>
    <DefiningExpression>
      'Ref(DiscontinuedProduct)'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Ref2"" ReturnType=""String"">
    <Parameter Name=""p"">
      <ReferenceType Type=""Self.Product""/>
    </Parameter>
    <DefiningExpression>
      'Ref(Product)'
    </DefiningExpression>
  </Function>
  <!-- overload resolution: row promotion/ranking -->
  <Function Name=""F_In_Row"" ReturnType=""String"">
    <Parameter Name=""p"">
      <RowType>
        <Property Name=""p1"" Type=""Self.DiscontinuedProduct""/>
        <Property Name=""p2"" Type=""Decimal""/>
      </RowType>
    </Parameter>
    <DefiningExpression>
      'Row(DiscProd,Decimal)'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Row"" ReturnType=""String"">
    <Parameter Name=""p"">
      <RowType>
        <Property Name=""p1"" Type=""Self.Product""/>
        <Property Name=""p2"" Type=""Int32""/>
      </RowType>
    </Parameter>
    <DefiningExpression>
      'Row(Prod,32)'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Row2"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Int32""/>
    <Parameter Name=""p2"">
      <RowType>
        <Property Name=""p1"" Type=""Self.Product""/>
        <Property Name=""p2"" Type=""Int32""/>
      </RowType>
    </Parameter>
    <Parameter Name=""p3"" Type=""Int32""/>
    <DefiningExpression>
      '32-r-32'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_Row2"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Decimal""/>
    <Parameter Name=""p2"">
      <RowType>
        <Property Name=""p1"" Type=""Self.Product""/>
        <Property Name=""p2"" Type=""Int32""/>
      </RowType>
    </Parameter>
    <Parameter Name=""p3"" Type=""Decimal""/>
    <DefiningExpression>
      'Decimal-r-Decimal'
    </DefiningExpression>
  </Function>
  <!-- overload resolution: col(row) promotion/ranking -->
  <Function Name=""F_In_ColRow"" ReturnType=""String"">
    <Parameter Name=""p"">
      <CollectionType>
        <RowType>
          <Property Name=""p1"" Type=""Self.DiscontinuedProduct""/>
          <Property Name=""p2"" Type=""Decimal""/>
        </RowType>
      </CollectionType>
    </Parameter>
    <DefiningExpression>
      'Col(Row(DiscProd,Decimal))'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_ColRow"" ReturnType=""String"">
    <Parameter Name=""p"">
      <CollectionType>
        <RowType>
          <Property Name=""p1"" Type=""Self.Product""/>
          <Property Name=""p2"" Type=""Int32""/>
        </RowType>
      </CollectionType>
    </Parameter>
    <DefiningExpression>
      'Col(Row(Prod,32))'
    </DefiningExpression>
  </Function>
  <Function Name=""F_In_ColRow2"" ReturnType=""String"">
    <Parameter Name=""p1"" Type=""Decimal""/>
    <Parameter Name=""p2"">
      <CollectionType>
        <RowType>
          <Property Name=""p1"" Type=""Self.Product""/>
          <Property Name=""p2"" Type=""Int32""/>
        </RowType>
      </CollectionType>
    </Parameter>
    <Parameter Name=""p3"" Type=""Decimal""/>
    <DefiningExpression>
      'Decimal-c(r)-Decimal'
    </DefiningExpression>
  </Function>
  <!-- positive(regression): function returns a boolean value -->
  <Function Name=""F_Ret_SBool"" ReturnType=""Boolean"">
    <DefiningExpression>
      <![CDATA[10 > 20]]>
    </DefiningExpression>
  </Function>";

        public static readonly string csdl = string.Format(csdlTemplate, "");

        public static readonly string csdlWithFunctions = string.Format(csdlTemplate, modelDefinedFunctions);
    }
}