I use this:
   public class ConstructionRepository
    {
        private CRDataContext db = new CRDataContext();
        public IQueryable<Material> FindAllMaterials()
        {
            //return db.Materials;
            var materials = from m in db.Materials
                            join Mt in db.MeasurementTypes on m.Measureme...
            
           
          
            
            I am querying an SQLite database using LINQ to NHibernate.
Person is an entity containing an Id and a Name:
public class Person
{
    public Guid Id { get; private set; }
    public string Name { get; private set; }
}
Let's say my db table contains a single person whose name is "John".
This test works as expected:
var query = from ...
            
           
          
            
            I use this to get a list of materials from my database....
  public IQueryable<MaterialsObj> FindAllMaterials()
    {
       var materials =  from m in db.Materials
           join Mt in db.MeasurementTypes on m.MeasurementTypeId equals Mt.Id
           select new MaterialsObj()
               {
                   Id = Convert.ToInt64(m...
            
           
          
            
            The following code doesn't seem to get the correct count.....
 var materials = consRepository.FindAllMaterials().AsQueryable();
 int count = materials.Count();
Is it the way to do it.... Here is my repository which fetches records...
public IQueryable<MaterialsObj> FindAllMaterials()
        {
           var materials =  from m in db...
            
           
          
            
            I want to get IQueryable<> result when executing stored procedure.  
Here is peace of code that works fine:  
IQueryable<SomeEntitiy> someEntities;  
var globbalyFilteredSomeEntities = 
  from se in m_Entities.SomeEntitiy
    where
      se.GlobalFilter == 1234 
  select se;
I can use this to apply global filter, and later use result...
            
           
          
            
            I have an interface called ICatalog as shown below where each ICatalog has a name and a method that will return items based on a Predicate<Item> function.
public interface ICatalog
{
     string Name { get; }
     IEnumerable<Item> GetItems(Predicate<Item> predicate);
}
A specific implementation of a catalog may be linked to catalogs ...
            
           
          
            
            So here's the thing: I've got an app that I'm testing that uses LINQ to Entities (EF4/.NET4). The app binds to an implementation of the Contains method that ignores nulls and, due to the way the database is configured, ignores case. That works great.
However, when I call into the same methods from my unit tests, I'm passing in a fake co...
            
           
          
            
            I am performing a select query using the following Linq expression:
Table<Tbl_Movement> movements = context.Tbl_Movement;
var query = from m in movements
            select new MovementSummary
            {
                Id = m.DocketId,
                Created = m.DateTimeStamp,
                CreatedBy = m.Tbl_User.FullName,
      ...
            
           
          
            
            I have been using these common EntityObjectFilters as a "pipes and filters" way to query from a collection a particular item with an ID:
public static class EntityObjectFilters
{
    public static T WithID<T>(this IQueryable<T> qry,
       int ID) where T : IEntityObject
    {
        return qry.SingleOrDefault<T>(item => item.ID == ID)...
            
           
          
            
            I'm working on a project that groups data by a "customer id". When the user logs in, they're limited to that customer and that customer only.
I'm working with SubSonic3, and what I've got looks something like this:
public IEnumerable<Models.Foo> FindFoo(int userID, string searchText, int pageIndex, int pageSize)
{
    return from item ...
            
           
          
            
            Hello. This is a question about the SYNTAX of c# and NOT about how we call/use IQueryable
Can someone please explain to me:
We have this declaration (System.Linq):
public static double Average<TSource>(this IQueryable<TSource> source,
                                      Expression<Func<TSource, int>> selector)
and to call the Aver...
            
           
          
            
            Here is my repository method which returns UserId ,
public IQueryable<int> getLoginStatus(string emailId, string password)
{
    return (from r in taxidb.Registrations
           where (r.EmailId == emailId && r.Password == password)
           select r.UserId);
}
How to return UserName which is a string along with UserId... Any sugge...
            
           
          
            
            I'm trying to decide on the best pattern for data access in my MVC application.
Currently, having followed the MVC storefront series, I am using repositories, exposing IQueryable to a service layer, which then applies filters. Initially I have been using LINQtoSQL e.g.
public interface IMyRepository
{
  IQueryable<MyClass> GetAll();
}
...
            
           
          
            
            Hi fellow programmer
I have a member class that returned IQueryable from a data context
    public static IQueryable<TB_Country> GetCountriesQ()
    {
        IQueryable<TB_Country> country;
        Bn_Master_DataDataContext db = new Bn_Master_DataDataContext();
        country = db.TB_Countries
            .OrderBy(o => o.CountryNam...
            
           
          
            
            I'm chaining search criteria in my application through IQueryable extension methods, e.g.:
public static IQueryable<Fish> AtAge (this IQueryable<Fish> fish, Int32 age)
{ 
    return fish.Where(f => f.Age == age);
}
However, I also have a full text search stored procedure:
CREATE PROCEDURE [dbo].[Fishes_FullTextSearch]
@searchtext nva...
            
           
          
            
            Hi, I have four tables in my database and i want to join that's and return record's and show that into searchController!
My query is this:
public IQueryable PerformSearch(string query)
{
    if (!string.IsNullOrEmpty(query))
    {
        var results = from tbl1 in context.Table1
                      join tbl2 in context.Table2 on tbl...
            
           
          
            
            I have a query as follows:
var query = from x in context.Employees
    where (x.Salary > 0 && x.DeptId == 5) || x.DeptId == 2
    order by x.Surname
    select x;
The above is the original query and returns let's say 1000 employee entities. 
I would now like to use the first query to deconstruct it and recreate a new query that would...
            
           
          
            
            How do you loop through IQueryable and remove some elements I don't need.
I am looking for something like this
var items = MyDataContext.Items.Where(x => x.Container.ID == myContainerId);
foreach(Item item in items)
{
  if(IsNotWhatINeed(item))
    items.Remove(item); 
}
Is it possible? Thanks in advance
...
            
           
          
            
            I know this could be opinion, but I'm looking for best practices.
As I understand, IQueryable implements IEnumerable, so in my DAL, I currently have method signatures like the following:
IEnumerable<Product> GetProducts();
IEnumerable<Product> GetProductsByCategory(int cateogoryId);
Product GetProduct(int productId);
Should I be usin...
            
           
          
            
            Hi , 
I have some methods in my BLL that fetch some records from database and pass it to UI for binding to Data Controls such as Gridview or ... 
I could choose my return data type of the methods whether IQueryable<t> or Ilist<t> .
 My question is which one would be better for me and why ? 
Actually i don't know the difference between t...