Hello,
I have the a question am going about his correctly I have a database for categories, it has many fields and about 4000 records, but with a Jquery autocomplete needing speed and the fact that I only need to return a key and category name. I did the following: (oh just to note, MVC2, Ajax project)
someclass.cs
public class categorySearch
{
public Guid Category_GUID { get; set; }
public string Category_Name { get; set; }
}
and now for the repository
Categoryrepository.cs
public class categoryRepository
{
internal List<categorySearch> FindCategory(string searchText, int maxResults)
{
List<categorySearch> category = new List<categorySearch>();
dbWebEntities storedb = new dbWebEntities();
var getcat = storedb.Categories.ToList();
foreach (var item in getcat)
{
category.Add(new categorySearch { Category_GUID = item.Cat_GUID, Category_Name = item.Category_Name});
}
var result = from c in category
where c.Category_Name.Contains(searchText)
orderby c.Category_Name
View Complete Post