Click here to Skip to main content
15,888,290 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have method in Bll Layer (use Stored Procedure ' SPShow() ')
C#
public static IList<Student> Show()
        {
            using (UniversityDataContext DB = new UniversityDataContext())
            {
                return (from t in DB.SPShow() select t).ToList<Student>();
            }            
        }


i want is good write for return type (IList) or no ?
if no i should use IQueryable or IEnumerable.If so, how should I convert ?
Posted

1 solution

Unless the callers need to change the result set then I'd recommend returning a IEnumerable of Students instead.

C#
public static IEnumerable<Student> Show() {
    using (var DB = new UniversityDataContext()) {
       return DB.SPShow(); // Might want to ToList here to prevent deferred execution
    }
}


Hope this helps,
Fredrik
 
Share this answer
 
Comments
Nekoomanesh 27-Sep-13 9:17am    
is good but when i want data show in Grid View have error :
Object reference not set to an instance of an object.

it's my code :
protected void btnShow_Click(object sender, EventArgs e)
{
GridView1.DataSource = StudentBLL.Show();
GridView1.DataBind();
}

What should I do؟
Fredrik Bornander 27-Sep-13 9:24am    
Debug it and figure out what's null. Then make sure that isn't null.

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