I know about covariance, and I know that in general it will not be possible in C# until v4.0.
However I am wondering about a specific case. Is there some way of getting converting IQueryable<Derived> to IQueryable<Base> by somehow creating a wrapper class that does not actually perform a query, but can actually "pass through" a .Wher...
Something so simple, but my head is hurting over it, I'm sure I can write this in one line when converting, but how?
IQueryable<ion> ions =FindAllions();
List<ionFormViewModel> ionFormViewModels = new List<ionFormViewModel>();
foreach (ion ion in ions)
{
ionFormViewModel ionFormViewModel = new ionFormViewModel(ion);
ionFormV...
Say I have a forum system with Threads, Posts and Tags.
The structure is the same as StackOverflow: Threads have a 1-many relationship to Posts, and Tags have a many-many relationship to Threads.
The (simplified) tables:
Thread
------
ThreadID int PK
Title varchar(200)
Tag
----
TagID int PK
Name varchar(50)
ThreadTag
-----------
T...
Hi There,
I am currently building a simple ASP.NET MVC site using Linq to Entities. My first foray into this world was nerd dinner, which is where I found the paginated list code that I am attempting to use. The code looks as follows:
public class PaginatedList<T> : List<T>
{
public int PageIndex { get; private set; }
public i...
I am passing a populated SelectList to my View and I want to default the selected value to the last record in the list. So far I've got:
IQueryable<BuildNumber> projBuildNos = tcRepository.GetProjectBuildNos();
BuildList = new SelectList(projBuildNos, "ID", "value", projBuildNos.Last().ID);
I get an exception saying "the query operat...
like say I want to make a method in my repository like
public IQueryable<Item> GetAllItemsByRange(int start, int end)
and then I just want to pass like (1, 100), (101, 200), (201, 300), etc so I can get back ONLY that range without having to get EVERYTHING at once
thanks!
...
I have this Linq Query
public IQueryable listAll()
{
ModelQMDataContext db = new ModelQMDataContext();
IQueryable lTax = from t
in db.tax
select new {Tax = t.tax1, Increase = t.increase};
return lTax;
}
how can I know the number of elements of lTax?
Thanks.
...
Can anybody explain me how to use (1) iQueryable (2) Expression Tree in c# by providing very basic example ? ( ofcourse both are not correlated,instead of making two separate questions,i wish to clear my doubt in a single question).
Advanced Thanks.
...
What is the use of IQueryable in the context of Linq.Is it used for developing extension methods or any other purpose?
...
I have two tables customers, pay and want to implement a gridview in silverlight with the outcome of the relationship of these two tables, the query is as follows
SELECT Pa.Tipo_Pagare, Pa.Pagare, Pa.Rut, Cli.Nombre
FROM Cred_Crexsa.dbo.Pagare AS Pa INNER JOIN
Cred_Crexsa.dbo.Clientes AS Cli ON Pa.Rut = Cli...
How can I convert an object System.Data.Linq.DataQuery to System.Linq.IQueryable
I'm working with Visual Basic/Silverlight and the source code of my query is as follows
Public Function Get_Cli_Pag() As IQueryable(Of V_Cliente_Pagare)
Dim Qry = From P In Me.Context.Pagares Join C In Me.Context.Codigos On C.Codigo
Equals ...
Hi everyone!!
I'm working in a ASP.NET MVC project and I have this particular situation: I have 3 pages - Product, Order, User. And in each of these pages I have a link calling the same ActionResult differing only by the argument passed depending on the page I'm in. For example:
public ActionResult(string typeOfPage)
{
if (typeOfPag...
I am returning IQueryable<Customer> to the other method for some querying operations. The return method looks like:
return from cust in _dbCustList
select new Customer
{
CustomerId = cust.Customer_Id,
FirstName= cust.First_Name,
LastName= cust.Last_Na...
I see a lot of code similar to the following
var customrs = MyDataContext.Customers.Where(...);
if (!String.IsNullOrEmpty(input)) {
customers = customers.Where(c => c.Email.Contains(input));
}
I would like to put this in an extension method that checks the input is valid before invoking Where on IQueryable so that it can be called l...
I want to create a DDD repository that returns IQueryable Entities that match the Linq to SQL underlying classes, minus any relations. I can easily return Entities minus the relations with a Linq select new {field, field, ... } projection. How do I code the Repository Entity class? How would I return an object from the repository havi...
Forgive me if this has been asked before; I couldn't find anything close after a few searches:
I'm trying to write an ActionFilter in MVC that will "intercept" an IQueryable and nullify all the parent-child relationships at runtime. I'm doing this because Linq does not serialize objects properly if they have parent-child relationships (...
Hi,
I have a simple linq statement that isn't quite returning what I would like. I understand why, I just don't know how to wriet it to get what I want.
The query is as follows:
answers = from a in ents.tblCalls
where a.tblSessions.tblUsers.UserID == UserID.Value
&& (a.StartTime >= sta...
I have the below call in my repository where I return IQueryable of Node (my business object class) then I have a filter function in my service layer which adds to the IQueryable call and filters the repository function GetNodes by id. When I return the FilterById as a list (so it executes) I get error -- The member 'bo.Node.Id' has no ...
Greetings, I am having some issues with using a bool operation within a Where clause extension method of an IQueryable object obtained using Linq to Entities. The first example is showing what does work using Bool1 as the operation I need to move to a where clause extension method. The second example is what doesn't work after the chan...
I'm trying to simulate:
WHERE x.IsActive = true OR x.Id = 5
The following causes 'AND' to be used... how do I simulate an 'OR' condition with IQueryable (qry) and my nullable int, given that other filtering might be involved as with the IsActive filter here?
if (onlyActiveItems) //bool
{
qry = q...