Created
September 10, 2012 18:41
-
-
Save davybrion/3692824 to your computer and use it in GitHub Desktop.
code snippets for "Hey Microsoft, Our Databases Aren’t Services!" post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implements application logic using the ChinookEntities context. | |
// TODO: Add your application logic to these methods or in additional methods. | |
// TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access | |
// Also consider adding roles to restrict access as appropriate. | |
// [RequiresAuthentication] | |
[EnableClientAccess()] | |
public class AlbumService : LinqToEntitiesDomainService<ChinookEntities> | |
{ | |
// TODO: Consider | |
// 1. Adding parameters to this method and constraining returned results, and/or | |
// 2. Adding query methods taking different parameters. | |
public IQueryable<Album> GetAlbum() | |
{ | |
return this.ObjectContext.Album; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void InsertAlbum(Album album) | |
{ | |
this.ObjectContext.AddToAlbum(album); | |
} | |
public void UpdateAlbum(Album currentAlbum) | |
{ | |
if ((currentAlbum.EntityState == EntityState.Detached)) | |
{ | |
this.ObjectContext.AttachAsModified(currentAlbum, this.ChangeSet.GetOriginal(currentAlbum)); | |
} | |
} | |
public void DeleteAlbum(Album album) | |
{ | |
if ((album.EntityState == EntityState.Detached)) | |
{ | |
this.ObjectContext.Attach(album); | |
} | |
this.ObjectContext.DeleteObject(album); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment