Skip to content

Instantly share code, notes, and snippets.

@KyleGobel
Created October 14, 2013 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyleGobel/6981336 to your computer and use it in GitHub Desktop.
Save KyleGobel/6981336 to your computer and use it in GitHub Desktop.
View From Entity Framework
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