Click here to Skip to main content
15,891,749 members
Home / Discussions / C#
   

C#

 
GeneralRe: re-cast of Control back to its Native Type ? Pin
BillWoodruff13-Oct-15 2:06
professionalBillWoodruff13-Oct-15 2:06 
GeneralRe: re-cast of Control back to its Native Type ? Pin
Pete O'Hanlon13-Oct-15 2:21
mvePete O'Hanlon13-Oct-15 2:21 
GeneralRe: re-cast of Control back to its Native Type ? Pin
BillWoodruff13-Oct-15 3:01
professionalBillWoodruff13-Oct-15 3:01 
AnswerRe: re-cast of Control back to its Native Type ? Pin
Eddy Vluggen13-Oct-15 1:42
professionalEddy Vluggen13-Oct-15 1:42 
GeneralRe: re-cast of Control back to its Native Type ? Pin
BillWoodruff13-Oct-15 2:18
professionalBillWoodruff13-Oct-15 2:18 
GeneralRe: re-cast of Control back to its Native Type ? Pin
Eddy Vluggen13-Oct-15 3:41
professionalEddy Vluggen13-Oct-15 3:41 
QuestionGet rows from database, Entity framework Pin
Member 1204569212-Oct-15 1:49
Member 1204569212-Oct-15 1:49 
AnswerRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 4:36
mveDave Kreskowiak12-Oct-15 4:36 
You haven't shown all the relevant code so it's impossible to be sure why it's not working.

But, I will say that your repository code doesn't return an IEnumerable<Product>. Your code is actually returning a DbSet<Product>, which just so happens to implement IEnumberable<TEntity> so the code doesn't throw an error when you compile it.

The set you're returning is empty because the query hasn't actually run. You have to call some method on the Products query, typically .ToList(), to force the query to run and build the list in memory. It's called "deferred execution[^]". If you're using Entity Framework you better understand what this is.

Your repository should looks more like this:
namespace SportsStore.domain.Concrete
{
    public class EFProductRepository : IProductRepository
    {
        private EFDbContext context = new EFDbContext();
 
        public IEnumerable<Product> Products
        {
            get { return context.Products.ToList(); }
        }
    }
}

A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 4:48
Member 1204569212-Oct-15 4:48 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 4:50
mveDave Kreskowiak12-Oct-15 4:50 
GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 5:09
Member 1204569212-Oct-15 5:09 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 5:14
mveDave Kreskowiak12-Oct-15 5:14 
GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 9:35
Member 1204569212-Oct-15 9:35 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 9:54
mveDave Kreskowiak12-Oct-15 9:54 
GeneralRe: Get rows from database, Entity framework Pin
Member 1204569212-Oct-15 10:30
Member 1204569212-Oct-15 10:30 
GeneralRe: Get rows from database, Entity framework Pin
Dave Kreskowiak12-Oct-15 10:33
mveDave Kreskowiak12-Oct-15 10:33 
Questionhow to read data from gps (TK103) in .net Pin
Member 454542811-Oct-15 6:34
professionalMember 454542811-Oct-15 6:34 
AnswerRe: how to read data from gps (TK103) in .net Pin
Dave Kreskowiak11-Oct-15 11:09
mveDave Kreskowiak11-Oct-15 11:09 
AnswerRe: how to read data from gps (TK103) in .net Pin
ZurdoDev13-Oct-15 2:59
professionalZurdoDev13-Oct-15 2:59 
Questionwant to add xlsm file in project and automatic copy the data of xlsm file in other side Pin
Member 1204967211-Oct-15 1:20
Member 1204967211-Oct-15 1:20 
AnswerRe: want to add xlsm file in project and automatic copy the data of xlsm file in other side Pin
OriginalGriff11-Oct-15 1:53
mveOriginalGriff11-Oct-15 1:53 
SuggestionRe: want to add xlsm file in project and automatic copy the data of xlsm file in other side Pin
Kornfeld Eliyahu Peter11-Oct-15 2:44
professionalKornfeld Eliyahu Peter11-Oct-15 2:44 
General2 texbox value transfar ti cobobox Pin
Member 1204736710-Oct-15 17:21
Member 1204736710-Oct-15 17:21 
QuestionIs this a secure way to encrypt? Pin
Jassim Rahma10-Oct-15 11:27
Jassim Rahma10-Oct-15 11:27 
AnswerRe: Is this a secure way to encrypt? Pin
ZurdoDev12-Oct-15 5:26
professionalZurdoDev12-Oct-15 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.