Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my DAL function.

C#
public IQueryable GetAllCategories()
        {
            CastroDataContext objDAL = new CastroDataContext();

            var varCategories = (from cat in objDAL.Categories
                                 where cat.IsDeleted.Equals(false)
                                 select new
                                 {
                                     CategoryID = this.ToInteger(cat.CategoryID),
                                     CategoryName = this.ToString(cat.CategoryName),
                                     Description = this.ToString(cat.Description),
                                     EvaluationType = this.ToString(cat.EvaluationType),
                                 });


            return varCategories;
        }


and i want to know that how to get the data at my front end in my combobox.

i am trying this
C#
protected void GetCategories()
        {            
            clsCategories DAL = new clsCategories();
            IQueryable ds = DAL.GetAllCategories();
            CastroDataContext db = new CastroDataContext();
            var query = from category in db.Categories select category;
                      
            foreach (var row in query)
            {
            
            }
}


But here are error.plz guaid me
Posted
Comments
[no name] 4-Mar-13 10:32am    
Do you expect us to guess what the errors are? Come on! You have been around long enough to know better.
prince_rumeel 4-Mar-13 10:35am    
I am new on Linq
[no name] 4-Mar-13 10:38am    
What does that have to do with anything? Does being new to LINQ mean you cannot copy/paste the errors you are getting? I am sure that you have been told this but I will tell you again, we are not mind readers and we cannot see your desktop to know what errors you see.
bbirajdar 4-Mar-13 11:04am    
Give me a weeks time to guess the error and may be I can guide you after that...

1 solution

Mostly if not ALL of your problem is in GetCategories()

Why are you running a query in your DAL and then trying to do the same in your GetCategories method?

I would firstly check to make sure that the ds variable has data inside of it when you run that routine (just in case you ask how? put a breakpoint on that line, step over it and through the debugger see what gets returned).

If that returns records, you can then do something like this

C#
 foreach(var row in ds)
 {
   //Do something to your data here
   //i.e. 
   int CategoryID = row.CategoryID;
 }


hopefully this should give you something to get started with.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900