Download presentation
Presentation is loading. Please wait.
Published byConor Duval Modified over 10 years ago
1
Václav Dajbych Microsoft Student Partner dajbych.net @Dajbych feed.dajbych.net events.dajbych.net
2
Relace Syntaxe Anotace Demo Model-View-ViewModel Srovnání s MVC Binding Demo
3
Automatické mapování Tříd na tabulky Vazeb tříd na relace tabulek Proxy Sledování změn Propagace změn do databáze voláním metody
5
Databáze SchémaTřídy DatabázeTřídy
6
V současnosti EF 4.1 RC Go-live licence Za dva týdny RTW SQL Server SQL Server Compact 4 Oracle
8
var house = ( from h in db.Houses select h).First(); var town = house ;.Town
9
class Town { int Id { get; set; } string Name { get; set; } House House { get; set; } } class House { int Id { get; set; } int Number { get; set; } Town Town { get; set; } }
10
class Town { int Id { get; set; } string Name { get; set; } ICollection Houses { get; set; } } class House { int Id { get; set; } int Number { get; set; } Town Town { get; set; } }
11
class Town { int Id { get; set; } string Name { get; set; } ICollection Houses { get; set; } } class House { int Id { get; set; } int Number { get; set; } ICollection Towns { get; set; } }
12
int int? string decimal DateTime bool bool? byte byte[] int, not null int nvarchar(128) decimal(18,2), not null datetime bit, not null bit tinyint, not null varbinary(max)
13
public class Town { public int Id { get; set; } public string Name { get; set; } virtual public virtual ICollection Houses { get; set; } class Entity : Town { public Entity() {...} override public override ICollection Houses { get {...} set {...} }
14
public class Table { public int Id { get; set; } public int? Value1 { get; set; } public string Value2 { get; set; } public decimal Value3 { get; set; } public decimal? Value4 { get; set; } public bool Value5 { get; set; } public bool? Value6 { get; set; } public byte Value7 { get; set; } public byte[] Value8 { get; set; } public DateTime Value9 { get; set; } }
15
public class DemoDb : DbContext { public DemoDb() : base(@"connection string") { var initializer = new DropCreateDatabaseIfModelChanges (); Database.SetInitializer(initializer); Database.CreateIfNotExists(); } public DbSet Table { get; set; } }
16
<add name="DatabaseCS" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=db.sdf" /> : base("name=DatabaseCS")
17
DropCreateDatabaseAlways DropCreateDatabaseIfModelChanges CreateDatabaseIfNotExists IgnoreDatabaseSchema
18
DbContext OnModelCreating ShouldValidateEntity ValidateEntity IDatabaseInitializer Seed
19
DbContext.ExecuteSqlCommand( "UPDATE t SET c = {1} WHERE id = {0}", 7, DateTime.Now );
20
[Key] // primary key [NotMapped] [MaxLength] // nvarchar(max) [StringLength(40)] // nvarchar(40) [Required]
22
Model View Controller
23
View ViewModel Model
24
Každý ovládací prvek má svůj datový kontext Jak ovládací prvek tak i datový kontext vyvolávají události, pokud se hodnota změní INotifyPropertyChanged INotifyCollectionChanged DependencyProperty ObservableCollection ICommand
25
Analogie s ASP.NET public string Text { get; set; } code behind pro oba případy stejný
27
Relace Syntaxe Anotace Demo Model-View-ViewModel Srovnání s MVC Binding Demo dajbych.net @Dajbych feed.dajbych.net events.dajbych.net
28
© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.