Sign in
Meta-Me
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
About
Email Blog Author
RSS for posts
Atom
RSS for comments
OK
Search
Tags
Astoria
C#
Code Only
Community
Data Services
DSP
EDM
EF
EF 4.0
EF Internals
Entity Framework
Expressions
Foreign Keys
Functional
IDataServiceQueryProvider
LINQ
LINQ to Entities
Metadata
Object Services
OData
Philosophical
Ramblings
Samples
Tips
Tricks
Archive
Archives
May 2013
(1)
December 2012
(2)
November 2012
(1)
August 2012
(2)
February 2012
(1)
June 2011
(2)
June 2010
(3)
March 2010
(2)
February 2010
(5)
January 2010
(10)
December 2009
(3)
November 2009
(9)
October 2009
(4)
September 2009
(3)
August 2009
(5)
July 2009
(8)
June 2009
(8)
May 2009
(9)
April 2009
(9)
March 2009
(10)
February 2009
(3)
January 2009
(7)
December 2008
(3)
November 2008
(2)
September 2008
(2)
July 2008
(1)
June 2008
(1)
May 2008
(7)
April 2008
(2)
March 2008
(3)
February 2008
(8)
January 2008
(2)
December 2007
(2)
November 2007
(11)
Posts
Subscribe via RSS
Sort by:
Most Recent
|
Most Views
|
Most Comments
Excerpt View
|
Full Post View
Meta-Me
Creating a Data Service Provider – Part 3 - IDataServiceMetadataProvider
Posted
over 3 years ago
by
Alex D James
10
Comments
UPDATE: I’ve made a few updates to the code / write-up to reflect refactors I’ve made as I’ve implemented more of the interfaces. This is Part 3 of my ongoing series on Creating a Data Service Provider , and in this post we’ll look at how to implement...
Meta-Me
Custom Data Service Providers
Posted
over 3 years ago
by
Alex D James
14
Comments
Introduction Data Services sits above a Data Service Provider, which is responsible for interacting with the underlying Data Source on behalf of the Data Service. Data Services ships with some internal providers, and makes it possible for you to...
Meta-Me
Creating a Data Service Provider – Part 2 – IServiceProvider & DataSources
Posted
over 3 years ago
by
Alex D James
2
Comments
To create a read-only Data Service Provider (or DSP) you need to implement two Data Services interfaces: IDataServiceMetadataProvider to provide the metadata and IDataServiceQueryProvider to handle the queries. But first Data Services needs a way to...
Meta-Me
Creating a Data Service Provider – Part 1 - Intro
Posted
over 3 years ago
by
Alex D James
1
Comments
One of the the coolest things about Data Services is its provider model. Any data-source can be exposed as an OData Data Service simply by implementing a few interfaces. SharePoint 2010 implements these interfaces to expose list data, and you can too...
Meta-Me
Tip 49 – How to find your Data Service bug
Posted
over 4 years ago
by
Alex D James
4
Comments
I’ve been playing around with creating a custom Astoria Data Service Provider , aka DSP, for a while now. So far I’d managed to get my metadata all setup, so browsing to $metadata works great. I’d got a few simple queries work. Basically everything was...
Meta-Me
Tip 48 – How to host a Data Service in WCF
Posted
over 4 years ago
by
Alex D James
1
Comments
Every wonder if you can host an Astoria Data Service in WCF? Well turns out the answer is yes, in fact once you’ve got your references set up etc it is pretty easy. Step 1 – Setting up your project Here is what my working project looks like: In this example...
Meta-Me
Tip 47 – How fix-up can make it hard to change relationships
Posted
over 4 years ago
by
Alex D James
2
Comments
Problem: Take this code: Category oldCategory = ctx.Categories .Include("Products") .First(c => c.Name == "Drink"); Category newCategory = new Category {Name = "Beverage"}; foreach(Product product in oldCategory.Products) { newCategory.Products...
Meta-Me
Tip 46 – How to exclude a property using Code-Only
Posted
over 4 years ago
by
Alex D James
1
Comments
This time a real simple one prompted by this question on StackOverflow. Problem: If you tell the Entity Framework about this class using Code-Only, by default every property becomes part of Entity, and as a result stored in the database. Usually this...
Meta-Me
Tip 45 – How to swap EF metadata at runtime.
Posted
over 4 years ago
by
Alex D James
3
Comments
Background By default the Entity Framework embeds its metadata inside your assembly as a resource. It also puts a connection string in the App or Web Config that references those resources something like this: <add name="BloggingEntities" connectionString...
Meta-Me
Tip 44 – How to navigate an OData compliant service
Posted
over 4 years ago
by
Alex D James
7
Comments
I recently did a crash course in Data Services and OData . While doing so I realized my notes might be useful for you guys. So here is my little cheat sheet to quickly get up to speed with OData Urls. Note: OData Services may not necessarily support all...
Meta-Me
Tip 43 – How to authenticate against a Data Service
Posted
over 4 years ago
by
Alex D James
0
Comments
Problem: When writing code against a Data Service, like say SharePoint , the client application must provide a valid set of credentials, or you will see a dreaded “401 Unathorized” response. For Silverlight applications hosted on the same site as...
Meta-Me
Interesting series of Posts exploring Code-Only
Posted
over 4 years ago
by
Alex D James
1
Comments
Daniel Wertheim left a couple of comments on Tip 42 , that point to a series of posts he has written about using Code-Only to write clean code. The series is really interesting as he delves into topics like: facades, relationships between non-public...
Meta-Me
Tip 42 – How to create a dynamic model using Code-Only
Posted
over 4 years ago
by
Alex D James
5
Comments
Background: When we give examples of how to use Code-Only we always start with a strongly typed Context derived from ObjectContext . This class is used to bootstrap the model. For example this (property bodies omitted for simplicity sake): public...
Meta-Me
Tip 41 – How to execute T-SQL directly against the database
Posted
over 4 years ago
by
Alex D James
4
Comments
Sometimes you’ll find you need to issue a query or command that the Entity Framework can’t support. In fact this problem is common to most ORMs, which is why so many of them have a backdoor to the database. The Entity Framework has a backdoor too… .NET...
Meta-Me
Tip 40 – How to materialize presentation models via L2E
Posted
over 4 years ago
by
Alex D James
5
Comments
Problem: Imagine that you have these entities public class Product { public int ID { get; set; } public string Name { get; set; } public virtual Category Category { get; set; } } public class Category { public int ID { get; set; } public string Name ...
Meta-Me
Tip 39 – How to set overlapping Relationships – EF 4.0 only
Posted
over 4 years ago
by
Alex D James
1
Comments
Scenario: In EF 4 we have FK relationships , available for the first time in .NET 4.0 Beta 2, so it is now possible to have a model something like this: public class Division { public int DivisionID {get;set} // Primary Key public string Name {get;set;...
Meta-Me
Tip 38 – How to use CodeOnly with Astoria
Posted
over 4 years ago
by
Alex D James
0
Comments
The normal way that you create an ADO.NET Data Services (aka Astoria) Service is by creating a class that derives from DataService<T>. public class BloggingService : DataService<BloggingEntities> And if you want to use Entity Framework...
Meta-Me
Code-Only best practices
Posted
over 4 years ago
by
Alex D James
3
Comments
There have been lots of posts on the EFDesign blog talking about how the features in Code Only have evolved. But very little covering what we think will be the best way to write the code. You may have seen code like this: var prodConf = builder.Entity<Product>...
Meta-Me
Tip 37 – How to do a Conditional Include
Posted
over 4 years ago
by
Alex D James
13
Comments
Problem Someone asked how to do a Conditional Include a couple of days ago on StackOverflow. They wanted to query for some entity (lets say Movies) and eager load some related items (lets say Reviews) but only if the reviews match some criteria (i.e....
Meta-Me
Tagging File Systems?
Posted
over 4 years ago
by
Alex D James
6
Comments
I had an interesting in passing conversation with someone today about tagging file systems… which reminded me of my own sordid past. Before I joined Microsoft, before I was an MVP, before I released Base4, I wrote something called XTend. At the time I...
Meta-Me
Tip 36 – How to Construct by Query
Posted
over 4 years ago
by
Alex D James
6
Comments
While writing my tips series and writing EF controllers for MVC I found that I regularly wanted to create and attach a stub entity . Unfortunately it isn’t quite that simple, you have to make sure the entity isn’t already attached first, otherwise...
Meta-Me
Tip 35 – How to write OfTypeOnly<TEntity>()
Posted
over 4 years ago
by
Alex D James
4
Comments
If you write a LINQ to Entities query like this: var results = from c in ctx.Vehicles.OfType<Car>() select c; It will bring back, Cars and any type that derives from Car, like say SportCar or SUV. If you just want Cars and you don’t want...
Meta-Me
Tip 34 – How to work with Updatable Views
Posted
over 4 years ago
by
Alex D James
16
Comments
UPDATE: thanks Zeeshan for pointing out that by default only non-nullable columns end up in the key for view backed entities. Imagine this situation, you have a view in your database, and it is updatable. Next you decide to use this view with the Entity...
Meta-Me
Tip 33 – How cascade delete really works in EF
Posted
over 4 years ago
by
Alex D James
6
Comments
Imagine that in your database you have a cascade delete on an FK relationship. Something like this: Here the Delete Rule says that when a Category is deleted all the related Products should be deleted too. If you generate an EF model from this database...
Meta-Me
Tip 32 – How to create a database from SSDL – EF 4 only
Posted
over 4 years ago
by
Alex D James
0
Comments
We recently released a CTP that extends EF 4 Beta 1 which included Code Only. You can read more about Code Only here , here and here . If you look at the walkthroughs for Code Only you will see code that looks something like this: // Create a builder...
Page 2 of 7 (151 items)
1
2
3
4
5
»