I learned C# back in 2006, and recently tried to get back into it. I have learned then that they added something called LINQ Extensions to C#3.0. Now I am familiar with extension methods, and I'm just pondering the specifics of those related to IEnumerables.
Earlier today, me and one of my colleagues were debating whether or not the fol...
HI all,
What all other libraries or frameworks we can use apart from NHIbernate?
Can linq work with entites as the NHIbernate does?
Can linq automatically generates entities for us?
Does the Data application block come with .NET 3.5 or some separate installation is required?
...
I have a List that includes IQueryAble inside as a property. I'm passing List to my View in MVC project. I iterate through the List using foreach. Inside the foreach:
Albums in type of List
<% foreach(var x in Albums){%>
<h1><%= x.Title %></h1>
<p><%= x.Photos.Count() %> </p>
<%}%>
Displaying the Title is not an issue, but it thro...
The scenario is like this:
name | val
'aa' | 10
'bb' | 20
'cc' | 30
*********
sum | 60
For now I just select all the records in simple LINQ query and invoke the enumerator (ToList())
Then I loop over the list and summarize the val column.
Is there a better way? LINQ selects all to a new typed object so I dont know how to add the ...
Hi, im trying to extract the most common YEAR from an array of DateTime objects using LINQ.
can someone help me? With the following its telling me i need to implement IComparable..
DateTime modeDate = (from c in dates
group c by c.Year into g
select g).Max(...
What are the major differences between Data Access Application Block, NHibernate, ADO.NET Entity Framework and LINQ to SQL with respect to performance, business logic, scalability and flexibility?
...
Hi,
Im fairly new to Linq and struggling using dynamic where over a many to many relationship.
Database tables are like so:
Products <-> Products_SubCategories <-> SubCategories
with Products_SubCategories being a link table.
My full linq statement is
db.Products.Where("it.SubCategories.SubCategoryID = 2")
.In...
Hello
I have a problem where I call a stored proedure twice, each with different parameters and I need 2 seperate lists but linq is caching the data and also giving me the error above
I have tried 2 different methods to get round the error message, one using ToList() on tbl and the other manually walking through the data
My code is sh...
I have a MVC that posts an array of int, and I want to convert that array of int's to IEnumerable<MyTestObj>, how is that done? I cant use myintArr.AsEnumerable() it seems.
...
Hi,
I have a database which consists of the following:
** Table 1 **
Id (PK)
Field1
** Table 2 **
Id (PK)
Field2
** Link Table **
Table1Id (FK)
Table2Id (FK)
The problem is, I cannot access Table 2 from Table 1, even though the relationship exists in the database.
For example, the following should be possible:
var Results...
public class ErrorLogModel
{
public int UnitID { get; set; }
public string Address { get; set; }
public IList<HardwareLogModel> _Hardware { get; set; }
}
public class SPLHardwareLogModel
{
public Guid HardwareID { get; set; }
public string HardwareDesc { get; set; }
public string HardwareStatus { get; set; }...
Hi, I'm trying to get my linq statement to get me all records between two dates, and I'm not quite sure what I need to change to get it to work: (a.Start >= startDate && endDate)
var appointmentNoShow =
from a in appointments
from p in properties
from c in clients
where a.Id == p.OID && (a.Start.Date >= startDate.Date &&...
I have a page which gives user to generate report based on different filters selected.
I need some suggestion or idea on my thoughts
Loop through each filter control
(checkbox, multi select list,
radiobox list) and build dynamic
where conditions and conjunctions
for each filter and then run query
Get all the data (i think this will
c...
I'm trying to convert DataTable to Linq
using
DIm result = From r in dt.AsEnumerable()
Select new ( col1 = r.Field<integer>("id"), col2 = r.Field<string>("desc"))
But i get error near 'new (' saying type expected.
What is wrong with this query?
...
Here's the setup:
public class Parent
{
public List<Child> ChildrenA = new List<Child>();
public List<Child> ChildrenB = new List<Child>();
}
public class Child
{
public Child (string name) {Name=name;}
public string Name {get;set;}
}
Having the following data:
var parents = new List<Parent>();
parents.Add (new Paren...
Hello!
I´ve got a problem when using LINQ to execute a stored procedure and return its values. One of the column that the stored procedure returns is of datatype image and contains a pdf in binary form.(this because the database is deployed on sql server 2000, otherwised i would choose a blob)
When including the stored procedure in my ...
Hello Friends,
I been trying to write the following code in expression based way but not sure how can i do that assignment to the object after comparison. Any help would be highly appreciated.
var pcs = from a in collection
group a by a.TotType
into g
select new
{
TType = g.Key,
SColl = g.Sel...
Here are two C# classes...
public class Address
{
public string Country;
public string City;
}
public class Traveller
{
public string Name;
public List<Address> TravelRoute;
}
... and a list of data (filled somewhere) ...
List<Traveller> Travellers;
... and then this LINQ query:
var result = from t in ...
(line of code of interest is the last one, the rest is just for a full representation)
Using the following code, I wanted to take VOTERS until I exceeded the maximum votes needed, but it stops right before reaching that maximum number of votes, so my voters pool has 1 fewer voter than I wanted.
Is there a clean way in LINQ where I cou...
Taking the following code, Resharper tells me that voicesSoFar and voicesNeededMaximum cause "access to a modified closure". I read about these but what puzzles me here is that Resharper suggests fixing this by extracting the variables to right before the LINQ query. But that is where they are already!
Resharper stops complaining if I m...