Created
October 14, 2013 20:03
-
-
Save KyleGobel/6981336 to your computer and use it in GitHub Desktop.
View From Entity Framework
This file contains 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 class CategoryFullPathRepository : ICategoryFullPathRepository | |
{ | |
protected DbContext DbContext { get; set; } | |
public CategoryFullPathRepository(DbContext dbContext) | |
{ | |
DbContext = dbContext; | |
} | |
public IEnumerable<CategoryFullPath> GetAllPaths() | |
{ | |
return DbContext.Database.SqlQuery<CategoryFullPath>("SELECT * FROM [Main].[Catalog].[vCategoryFullPath]"); | |
} | |
public CategoryFullPath GetPathByCategory(int id) | |
{ | |
return | |
DbContext.Database.SqlQuery<CategoryFullPath>( | |
"SELECT * FROM [Main].[Catalog].[vCategoryFullPath] WHERE [ID] == " + id).FirstOrDefault(); | |
} | |
public CategoryFullPath GetPathByCategory(CatalogCategory category) | |
{ | |
return GetPathByCategory(category.Id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment