File: TestModels.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 (401 lines) | stat: -rw-r--r-- 11,561 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
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.

namespace System.Data.Entity.Migrations
{
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Data.Entity.Spatial;
    using System.Data.SqlServerCe;

    public class MigrationsCustomer
    {
        public MigrationsCustomer()
        {
            DateOfBirth = DateTime.Now;
            HomeAddress = new MigrationsAddress();
            WorkAddress = new MigrationsAddress();
        }

        public int Id { get; set; }
        public long CustomerNumber { get; set; }
        public string Name { get; set; }
        public string FullName { get; set; }
        public DateTime DateOfBirth { get; set; }
        public byte Age { get; set; }
        public MigrationsAddress HomeAddress { get; set; }
        public MigrationsAddress WorkAddress { get; set; }
        public ICollection<Order> Orders { get; set; }

        [MaxLength(1024)]
        public byte[] Photo { get; set; }
    }

    public class SpecialCustomer : MigrationsCustomer
    {
        public int Points { get; set; }
    }

    public class GoldCustomer : MigrationsCustomer
    {
        [Column("Gold_Points")]
        public int Points { get; set; }
    }

    [ComplexType]
    public class MigrationsAddress
    {
        [MaxLength(150)]
        public string City { get; set; }
    }

    [Table("Orders", Schema = "ordering")]
    public class Order
    {
        public int OrderId { get; set; }
        public string Type { get; set; }

        [Timestamp]
        public byte[] Version { get; set; }

        public ICollection<OrderLine> OrderLines { get; set; }
    }

    public class OrderLine
    {
        public int Id { get; set; }
        public int OrderId { get; set; }
        public short Quantity { get; set; }
        public decimal Price { get; set; }

        [Column(TypeName = "money")]
        public decimal Total { get; set; }

        public bool? IsShipped { get; set; }
        public int ProductId { get; set; }

        [MaxLength(128)]
        public string Sku { get; set; }
    }

    public class MigrationsProduct
    {
        [Key]
        [Column(Order = 0)]
        public int ProductId { get; set; }

        [Key]
        [Column(Order = 1)]
        [MaxLength(128)]
        public string Sku { get; set; }

        public string Name { get; set; }

        public byte[] Image { get; set; }
    }

    public class MigrationsStore
    {
        public int Id { get; set; }
        public string Name { get; set; }

        public MigrationsAddress Address { get; set; }
        public DbGeography Location { get; set; }
        public DbGeometry FloorPlan { get; set; }
        public StoreKind Kind { get; set; }

        [Timestamp]
        public byte[] RowVersion { get; set; }
    }

    public enum StoreKind
    {
        Mall,
        HighStreet,
        Embedded,
    }

    public class ShopContext_v1 : DbContext
    {
        public ShopContext_v1()
        {
        }

        public ShopContext_v1(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
        }

        public DbSet<MigrationsCustomer> Customers { get; set; }
        public DbSet<MigrationsProduct> Products { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<OrderLine>().Ignore(c => c.Total);
            modelBuilder.Entity<Order>().Property(o => o.Type).IsUnicode(false);
            modelBuilder.Entity<MigrationsProduct>();
        }
    }

    public class ShopContext_v2 : ShopContext_v1
    {
        public ShopContext_v2()
        {
        }

        public ShopContext_v2(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<MigrationsCustomer>().ToTable("tbl_customers", "crm");

            if (!(Database.Connection is SqlCeConnection))
            {
                // NotSupported in CE
                modelBuilder.Entity<MigrationsCustomer>().Property(c => c.Name).HasColumnName("new_name");
            }

            modelBuilder.Entity<MigrationsCustomer>().Property(c => c.FullName).HasMaxLength(25);

            modelBuilder.Entity<Order>().Property(o => o.Type).IsUnicode(false);
            modelBuilder.Entity<Order>().HasMany(o => o.OrderLines).WithOptional().WillCascadeOnDelete(false);

            modelBuilder.Entity<OrderLine>().Ignore(ol => ol.IsShipped);
            modelBuilder.Entity<OrderLine>().HasKey(
                ol => new
                          {
                              ol.Id,
                              ol.OrderId
                          });
            modelBuilder.Entity<MigrationsProduct>();
        }
    }

    public class ShopContext_v3 : ShopContext_v2
    {
        public ShopContext_v3()
        {
        }

        public ShopContext_v3(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
        }

        public DbSet<MigrationsStore> Stores { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            this.IgnoreSpatialTypesOnSqlCe(modelBuilder);
        }
    }

    public class ShopContext_v4 : ShopContext_v3
    {
        public ShopContext_v4()
        {
        }

        public ShopContext_v4(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder
                .Entity<MigrationsStore>()
                .Property(s => s.Name)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
        }
    }

    public class ShopContext_v5 : ShopContext_v1
    {
        public ShopContext_v5()
        {
        }

        public ShopContext_v5(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.HasDefaultSchema("non_default_schema");
        }
    }

    public class EmptyModel : DbContext
    {
    }

    public class NonEmptyModel : DbContext
    {
        public DbSet<MigrationsBlog> Blogs { get; set; }
    }

    public class MigrationsBlog
    {
        public int MigrationsBlogId { get; set; }
        public string Url { get; set; }
    }

    internal class MappingScenariosContext : DbContext
    {
        public DbSet<MigrationsEmployee> Employees { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<MigrationsEmployee>()
                .HasOptional(e => e.Manager)
                .WithMany(m => m.DirectReports);
        }
    }

    internal class MigrationsEmployee
    {
        public int Id { get; set; }

        public int? ManagerId { get; set; }
        public MigrationsEmployee Manager { get; set; }

        public ICollection<MigrationsEmployee> DirectReports { get; set; }
    }

    public class TypeCasts
    {
        public int Id { get; set; }

        public byte ByteToInt16 { get; set; }
        public byte ByteToInt32 { get; set; }
        public byte ByteToInt64 { get; set; }
        public short Int16ToInt32 { get; set; }
        public short Int16ToInt64 { get; set; }
        public int Int32ToInt64 { get; set; }
        public decimal Decimal6ToSingle { get; set; }
        public decimal Decimal6ToDouble { get; set; }
        public decimal Decimal7ToSingle { get; set; }
        public float SingleToDecimal11 { get; set; }
        public float SingleToDouble { get; set; }
        public float SingleToDecimal16 { get; set; }
        public decimal Decimal15ToDouble { get; set; }
        public double DoubleToDecimal16 { get; set; }

        #region Version 2

        [Column("ByteToInt16")]
        public short ByteToInt16_v2 { get; set; }

        [Column("ByteToInt32")]
        public int ByteToInt32_v2 { get; set; }

        [Column("ByteToInt64")]
        public long ByteToInt64_v2 { get; set; }

        [Column("Int16ToInt32")]
        public int Int16ToInt32_v2 { get; set; }

        [Column("Int16ToInt64")]
        public long Int16ToInt64_v2 { get; set; }

        [Column("Int32ToInt64")]
        public long Int32ToInt64_v2 { get; set; }

        [Column("Decimal6ToSingle")]
        public float Decimal6ToSingle_v2 { get; set; }

        [Column("Decimal6ToDouble")]
        public double Decimal6ToDouble_v2 { get; set; }

        [Column("Decimal7ToSingle")]
        public float Decimal7ToSingle_v2 { get; set; }

        [Column("SingleToDecimal11")]
        public decimal SingleToDecimal11_v2 { get; set; }

        [Column("SingleToDouble")]
        public double SingleToDouble_v2 { get; set; }

        [Column("SingleToDecimal16")]
        public decimal SingleToDecimal16_v2 { get; set; }

        [Column("Decimal15ToDouble")]
        public double Decimal15ToDouble_v2 { get; set; }

        [Column("DoubleToDecimal16")]
        public decimal DoubleToDecimal16_v2 { get; set; }

        #endregion
    }

    public class Comment
    {
        public int Id { get; set; }
        public int? MigrationsBlogId { get; set; }
        public MigrationsBlog Blog { get; set; }
    }

    namespace UserRoles_v1
    {
        public class Role
        {
            public long Id { get; set; }
            public virtual ICollection<User> AssignedUsers { get; set; }
        }

        public class User
        {
            public long Id { get; set; }
            public virtual ICollection<Role> AssignedRoles { get; set; }
        }
    }

    namespace UserRoles_v2
    {
        public class Role
        {
            public long Id { get; set; }
            public virtual ICollection<User2> AssignedUsers { get; set; }
        }

        public class User2
        {
            public long Id { get; set; }
            public virtual ICollection<Role> AssignedRoles { get; set; }
        }
    }

    public class ProcessedTransactionContext : DbContext
    {
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder
                .Entity<ProcessedTransaction>()
                .HasMany(e => e.ChildTransactions)
                .WithOptional()
                .HasForeignKey(e => e.ParentTransactionId);
        }
    }

    public class ProcessedTransaction
    {
        public int Id { get; set; }

        public int? ParentTransactionId { get; set; }

        public virtual ProcessedTransaction ParentTransaction { get; set; }

        public virtual ICollection<ProcessedTransaction> ChildTransactions { get; set; }
    }
}