WPH304 LINQ to SQL LINQ to User Data LINQ Objects XML SQL User Data OData ItemReferenceData PK Categories ItemId PK FK1 ItemName ItemDescription CategoryId CategoryId CategoryName Stores ListItems Lists PK ListId PK FK1 ListName FK2 ListItemId ListItemName ListId Quantity Category Description StoreId History Favorites PK FK1 FavoriteItemId FavoriteItemName FavoriteItemCategory FavoriteItemQuantity FavoriteItemDescription FavoriteItemListId FavoriteItemPhoto PK PK FK1 HistoryItemId HistoryItemName HistoryItemCategory HistoryItemQuantity HistoryItemDescriptioin HistoryItemDateAdded HistoryItemListId HistoryItemPhoto StoreId StoreName StoreLocationLat StoreLocationLong StoreAddressLine1 StoreAddressLine2 StoreAddressCity StoreAddressState StoreAddressCountry StoryAddressZip Words PK WordId Word Pronunciation Definition AlternateSpellings Origin Favorites PK FavoriteId FK1 WordId History PK HistoryItemId FK1 WordId AddedDate.
Download
Report
Transcript WPH304 LINQ to SQL LINQ to User Data LINQ Objects XML SQL User Data OData ItemReferenceData PK Categories ItemId PK FK1 ItemName ItemDescription CategoryId CategoryId CategoryName Stores ListItems Lists PK ListId PK FK1 ListName FK2 ListItemId ListItemName ListId Quantity Category Description StoreId History Favorites PK FK1 FavoriteItemId FavoriteItemName FavoriteItemCategory FavoriteItemQuantity FavoriteItemDescription FavoriteItemListId FavoriteItemPhoto PK PK FK1 HistoryItemId HistoryItemName HistoryItemCategory HistoryItemQuantity HistoryItemDescriptioin HistoryItemDateAdded HistoryItemListId HistoryItemPhoto StoreId StoreName StoreLocationLat StoreLocationLong StoreAddressLine1 StoreAddressLine2 StoreAddressCity StoreAddressState StoreAddressCountry StoryAddressZip Words PK WordId Word Pronunciation Definition AlternateSpellings Origin Favorites PK FavoriteId FK1 WordId History PK HistoryItemId FK1 WordId AddedDate.
WPH304
LINQ to SQL
LINQ to User Data
LINQ
Objects
XML
SQL
User
Data
OData
ItemReferenceData
PK
Categories
ItemId
PK
FK1
ItemName
ItemDescription
CategoryId
CategoryId
CategoryName
Stores
ListItems
Lists
PK
ListId
PK
FK1
ListName
FK2
ListItemId
ListItemName
ListId
Quantity
Category
Description
StoreId
History
Favorites
PK
FK1
FavoriteItemId
FavoriteItemName
FavoriteItemCategory
FavoriteItemQuantity
FavoriteItemDescription
FavoriteItemListId
FavoriteItemPhoto
PK
PK
FK1
HistoryItemId
HistoryItemName
HistoryItemCategory
HistoryItemQuantity
HistoryItemDescriptioin
HistoryItemDateAdded
HistoryItemListId
HistoryItemPhoto
StoreId
StoreName
StoreLocationLat
StoreLocationLong
StoreAddressLine1
StoreAddressLine2
StoreAddressCity
StoreAddressState
StoreAddressCountry
StoryAddressZip
Words
PK
WordId
Word
Pronunciation
Definition
AlternateSpellings
Origin
Favorites
PK
FavoriteId
FK1
WordId
History
PK
HistoryItemId
FK1
WordId
AddedDate
Cloud
service
Windows Phone
Filter
Apps store private data in Isolated Storage
App Root Folder
Install
Package
Manager
Creates root folder
sandboxed to App
Database
file (r/o)
App Data Folder
App
WP7 Isolated
Storage APIs
Creates/manages
files and settings
Application
Settings file
Database file
Application
files
var query = from w in db.Wines
where w.Country == “USA"
select w.Name;
.Call System.Linq.Queryable.Select( .Call System.Linq.Queryable.Where(
.Constant(Table(Wines)), '(.Lambda #Lambda1)), '(.Lambda #Lambda2))
.Lambda #Lambda1(db.Wines $w) { $w.Country == “USA" } .Lambda
#Lambda2(w.Country $w) { $w.Name }
select Name
from Wines
where Country = “USA”
Custom
data
context
Object
materialization
App
objects
Identity
management
Change
tracking
Update
processing
Core ADO.NET (System.Data)
SQLCE ADO.NET Provider (System.Data.SqlServerCe)
Design time
Varietals
Wines
Vineyards
WineMakers
Run time
Wines
Varietals
PK
VarietalID
PK
WineID
FK2
FK1
Name
Description
RetailPrice
VarietalID
VineyardID
Name
Database
upgrade
Winemaker
Vineyards
PK
VineyardID
Name
Latitude
Longitude
Country
PK
WinemakerID
FirstName
LastName
// Define the data context.
public partial class WineDataContext : DataContext
{
public Table<Wine> Wines;
public Table<Vineyard> Vineyards;
public WineDataContext(string connection) : base(connection) { }
}
// Define the tables in the database
[Table]
public class Wine
{
[Column(IsPrimaryKey=true]
public string WineID { get; set; }
[Column]
public string Name { get; set; }
……
}
// Create the database form data context, using a connection string
DataContext db = new WineDataContext("isostore:/wineDB.sdf");
if (!db.DatabaseExists()) db.CreateDatabase();
// Create the database form data context, using a connection string
DataContext db = new WineDataContext("isostore:/wineDB.sdf");
// Find all wines currently at home, ordered by date acquired
var q = from w in db.Wines
where w.Varietal.Name == “Shiraz” && w.IsAtHome == true
orderby w.DateAcquired
select w;
Your app code
Name
Yellow Tail
Name
Little
Penguin
Varietal
Pinot Noir
Varietal
Pinot Noir
AtHome
True
AtHome
False
True
Insert
Wine newWine = new Wine
{
WineID = “1768",
Name = “Windows Phone Syrah",
Description = “Bold and spicy"
};
Update
Wine wine =
(from w in db.Wines
where w.WineID == “1768"
select w).First();
wine.Description = “Hints of plum and
melon";
db.Wines.InsertOnSubmit(newWine);
db.SubmitChanges();
db.SubmitChanges();
Delete
var vineyardsToDelete =
from Vineyards v in db.Vineyards
where v.Country == “Australia”
select v;
db.Vineyards.DeleteAllOnSubmit
(vineyardsToDelete);
db.SubmitChanges();
Foreign key constraint will cause
exception here if Wines
associated with the Vineyards
are not deleted first
var vineyardsToDelete =
from Vineyards v in db.Vineyards
where v.Country == “Australia"
select v;
foreach (Vineyards v in vineyardsToDelete)
{
db.Wines.DeleteAllOnSubmit(v.Wines);
}
db.Vineyards.DeleteAllOnSubmit(vineyardsToDelete);
db.SubmitChanges();
WineDataContext wineDC = new WineDataContext(App.WineDBConnectionString);
DatabaseSchemaUpdater dsu = wineDC.CreateDatabaseSchemaUpdater();
if (dsu.DatabaseSchemaVersion == 1)
{
dsu.AddColumn<Wine>("BottleType");
dsu.DatabaseSchemaVersion = 2;
dsu.Execute();
}
EmailAddressChooserTask
PhoneNumberChooserTask
private AddressChooserTask addressChooserTask;
// Constructor
public MainPage()
{
this.addressChooserTask = new AddressChooserTask();
this.addressChooserTask.Completed += new
EventHandler<AddressResult>(
addressChooserTask_Completed);
}
private void addressChooserTask_Completed(object sender, AddressResult e)
{
if (null == e.Error && TaskResult.OK == e.TaskResult)
{
... = e.DisplayName;
... = e.Address;
}
}
Contact name
and picture
Other contact data
Appointments/events
Windows Live Social
YES
YES
YES
Windows Live Rolodex
(user created and SIM import)
YES
YES
n/a
Exchange accounts
(corporate plus Google, etc.)
YES
YES
YES
Operator Address Books
YES
YES
n/a
Facebook
YES
NO
NO
Other networks in the People Hub
(e.g., Twitter)
NO
NO
NO
Contacts contacts = new Contacts();
contacts.SearchCompleted += new
EventHandler<ContactsSearchEventArgs>((sender, e) =>
{
... = e.Results;
});
// E.g. search for all contacts
contacts.SearchAsync(string.Empty, FilterKind.None, null);
filter expression
(not a regex)
state
Filter kind: name, email ,
phone or pinned to start)
// E.g. search for all contacts with display name matching "ja"
contacts.SearchAsync("ja", FilterKind.DisplayName, null);
Appointments appointments = new Appointments();
appointments.SearchCompleted += new
EventHandler<AppointmentsSearchEventArgs>((sender, e) =>
{
... = e.Results;
});
start date and time
// E.g. get next appointment (up to 1 week away)
appointments.SearchAsync(DateTime.Now,
DateTime.Now + TimeSpan.FromDays(7),
1, null);
end date and time
Maximum items to return
state
QUESTIONS?
How do you enter?
How am I selected?
During each
Windows Phone
session the moderator
will post a question;
the first person to
correctly answer the
question and is called
on by the moderator will
potentially win
* Restrictions apply please see
contest rules for eligibility and
restrictions. Contest rules are
displayed in the Technical
Learning Center at the
WPH info counter
Visit the
Windows Phone Technical Learning Center
for demos and more…
Business IT
resources
Developer
resources
blogs.technet.com/b/
windows_phone_4_it_pros
create.msdn.com
Experience Windows Phone 7 on-line
and get a backstage pass
www.windowsphone.com
http://northamerica.msteched.com
www.microsoft.com/teched
www.microsoft.com/learning
http://microsoft.com/technet
http://microsoft.com/msdn