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
Tip 31 – How to compose L2O and L2E queries
Posted
over 4 years ago
by
Alex D James
2
Comments
Imagine you want to write a query like this: var possibleBuyers= from p in ctx.People where p.Address.City == “Sammamish” && InMarketForAHouse(p) select p; Now theoretically this is possible so long as there is a SQL translation for InMarketForAHouse...
Meta-Me
Tip 30 – How to use a custom database function
Posted
over 4 years ago
by
Alex D James
11
Comments
Imagine you have a database function like the DistanceBetween function in Nerd Dinner : CREATE FUNCTION [dbo].[DistanceBetween]( @Lat1 as real, @Long1 as real, @Lat2 as real, @Long2 as real) RETURNS real AS BEGIN … END And you want to use it...
Meta-Me
Another C# trick: Fluents, Inheritance and Extension Methods
Posted
over 4 years ago
by
Alex D James
12
Comments
Here’s a scenario which Damien and I encountered recently. We needed a way of specifying Facets for properties on Entities, i.e. things like Nullable , MaxLength , Precision etc. And we needed a class hierarchy because different types of properties...
Meta-Me
Tip 29 – How to avoid LazyLoad or Load() reader issues
Posted
over 4 years ago
by
Alex D James
1
Comments
If you have code that looks like this: var results = from c in ctx.Customers where c.SalesPerson.EmailAddress == “…” select c; foreach(var customer in results) { Console.WriteLine(customer.Name); if (IsInteresting(customer)) { customer.Orders.Load...
Meta-Me
Some comments on efficient SOA method composition
Posted
over 4 years ago
by
Alex D James
2
Comments
A couple of posts back I started talking about composing SOAPY operations efficiently, by shipping intent to the service. An interesting debate ensued in my comments: Kristofer (the guy behind the Huagati tools for DBML and EDMX , and it seems a man after...
Meta-Me
And while you are at it… why can’t I compose REST calls?
Posted
over 4 years ago
by
Alex D James
0
Comments
In my last post I asked why you can’t compose SOA method calls efficiently. With REST services like ADO.NET Data Services having nice uniform URLs too, and a model (aka EDM) why can’t I compose those with my SOA methods too: i.e. expounding on my...
Meta-Me
Why can’t I efficiently compose method calls in SOA?
Posted
over 4 years ago
by
Alex D James
14
Comments
Imagine if you have these 3 methods: public Employee GetEmployee(string alias); public Department GetDepartment(Employee employee); public Employee GetManager(Department department); Now imagine if you want to find the Manager of the Department that some...
Meta-Me
Tip 28 - How to implement an Eager Loading strategy
Posted
over 4 years ago
by
Alex D James
20
Comments
Background: Over the last 2 years lots of people have complained about the way Eager loading works in the Entity Framework, or rather the way you ask the Entity Framework to eagerly load. Here is how you do it: var results = from b in ctx.Blogs.Include...
Meta-Me
A silly C# trick from the trenches
Posted
over 4 years ago
by
Alex D James
7
Comments
UPDATE: as Joe rightly points out in the comments (thanks Joe) when you try to pass a Func<T,V> to a method expecting Action<T> using lambda syntax it doesn't fail. Somehow the compiler must realize there is no match for Func<T,V> and...
Meta-Me
I never knew: C# method overloads can return different types
Posted
over 4 years ago
by
Alex D James
4
Comments
I came to C# from Java, which I’m pretty sure doesn’t (or maybe didn't) allow this, so I was super surprised today when I learnt that C# method overloads can have different return types. So this class is completely valid: public class Foo { public...
Meta-Me
Tip 27 – How to Implement BeforeSave Validation
Posted
over 4 years ago
by
Alex D James
4
Comments
It is common to want to validate that your entities are ‘valid’ before you save them to the database. A naive form of validation might be to try to ensure that your entities are ‘valid’ before you add them to the context, but this doesn’t help you if...
Meta-Me
New EF blogger – Craig Lee
Posted
over 4 years ago
by
Alex D James
0
Comments
Short one this time. Craig Lee , a colleague of mine who works on the tools team, has just started blogging. He already has a number of posts, including an interesting one on keyboard shortcuts . Enjoy.
Meta-Me
Tip 26 – How to avoid database queries using Stub Entities
Posted
over 4 years ago
by
Alex D James
21
Comments
What are Stub Entities? A stub entity is a partially populated entity that stands in for the real thing. For example this: Category c = new Category {ID = 5}; is a stub entity. It has only the ID populated, which indicates this is a stub...
Meta-Me
Wrapping Providers
Posted
over 4 years ago
by
Alex D James
1
Comments
For well over a year now I've been talking about how it is possible with EF to write a provider that sits between the EF and the native database provider. There are lots of reasons why you might do this. Here are some examples, you could write a: Tracing...
Meta-Me
Tip 25 – How to Get Entities by key the easy way
Posted
over 4 years ago
by
Alex D James
5
Comments
Sometimes rather than writing this: var customer = ctx.Customers.First(c => c.ID == 5); You would rather write something like this: var customer = ctx.Customers.GetCustomerById(5); In .NET 4.0 this would be trivial to do by modifying the...
Meta-Me
Tip 24 – How to get the ObjectContext from an Entity
Posted
over 4 years ago
by
Alex D James
7
Comments
Customers often ask how to get from an Entity back to the ObjectContext . Now generally we don’t recommend trying this. But sometimes you really need a way to get to the ObjectContext . For example if you are in method and all you have is the Entity...
Meta-Me
Tip 23 – How to fake Enums in EF 4
Posted
over 4 years ago
by
Alex D James
51
Comments
As of right now Enums are not in EF4. Now we will be listening to your feedback about Beta1, and making some adjustments, so you never know, but at the moment it doesn’t look like they will be supported. Yesterday though I came up with a workaround...
Meta-Me
Ordering of Commands – What do you think?
Posted
over 4 years ago
by
Alex D James
5
Comments
Some of our customers write code like this: ctx.AddToCustomers(customer); ctx.AddToProducts(product1); ctx.AddToProducts(product2); And expect the Entity Framework to issue 3 insert commands in the same order. Today the EF doesn’t preserve this sort of...
Meta-Me
Tip 22 - How to make Include really Include
Posted
over 4 years ago
by
Alex D James
22
Comments
This is 22nd post in my ongoing series of Entity Framework Tips . If you want to do eager loading with the Entity Framework it is generally really easy, you simply write something like this: var results = from post in ctx.Posts.Include(“Comments”)...
Meta-Me
An enumeration of one?
Posted
over 4 years ago
by
Alex D James
1
Comments
Having something enumerable is the gateway to all LINQ’s loveliness. But sometimes you have just one object. So how do you make that enumerable? var people = new Person[] {person}; Not exactly hard huh? In fact you can simplify this even more, you can...
Meta-Me
Learn about EF Pluralization Services courtesy of Dan Rigsby
Posted
over 4 years ago
by
Alex D James
1
Comments
Not long ago I wrote a ‘sneak peek’ for our new Pluralization features on the ADO.NET team blog. There is a more indepth post coming soon… But it seems the community is starting to do our education for us, and beating us (or should I say me) to the punch...
Meta-Me
Tip 21 – How to use the Single() operator – EF 4.0 only
Posted
over 4 years ago
by
Alex D James
3
Comments
This is 21st post in my ongoing series of Entity Framework Tips , and the first that is specific to EF 4.0. Entity Framework 4.0 Beta 1 As you’ve probably heard VS 2010 Beta 1 is now available to subscribers which means some of you can get your hands...
Meta-Me
Tip 20 – How to deal with Fixed Length Keys
Posted
over 4 years ago
by
Alex D James
6
Comments
This is 20th post in my ongoing series of Entity Framework Tips . Fixed Length Field Padding: If you have an fixed length column in the database, for example something like NCHAR(10) when you do an insert, padding happens automatically. So for example...
Meta-Me
Tip 19 – How to use Optimistic Concurrency with the Entity Framework
Posted
over 4 years ago
by
Alex D James
9
Comments
This is the 19th post in my ongoing series of Entity Framework Tips . Background: If you have a table with a timestamp column, and you reverse engineer an Entity from that table, you will end up with a Binary property in your entity (in my example...
Meta-Me
Tip 18 – How to decide on a lifetime for your ObjectContext
Posted
over 4 years ago
by
Alex D James
12
Comments
One of the most common questions we get is how long should an ObjectContext should live. Options often cited include one per: Function Form Thread Application Plenty of people are asking these types of questions, case in point here is a question on Stackflow...
Page 3 of 7 (151 items)
1
2
3
4
5
»