I want to group items from a linq query under a header, so that for each header I have a list of objects that match the header title. I assumed the solution would be to use ToDictionary to convert the objects, but this allows only one object per "group" (or dictionary key). I assumed I could create the dictionary of type (String, List Of...
I'm not sure how to ask this, but I want to create a new object in a linq statement, and initialize it's values. Since I have to use StructureMap's GetInstance method to get an instance of the object, I don't think this is possible. Am I wrong? And before we get off-topic, I realize I could probably create a constructor that takes the...
I'm getting an Entity Framework object collection from my Products table called oProducts. I am looping through the collection and setting the Quantity field from a separate function. Before I write out a display of the objects in HTML, I want to sort them by the Quantity. So, I am using LINQ to create a new collection and try to orde...
This sound simple but it not that much.
I want to order a List based on one of the properties of T, which is double type.
...
what is the linq equivalent of the following:
SELECT Mytable.A, MyTable.B, SUM(MyTable.C)
FROM MyTable
GROUP BY Mytable.A, MyTable.B
ORDER BY Mytable.A, MyTable.B
This is trivial in SQL, but seems to be very difficult in LINQ. What am I missing?
...
I have next very non-optimized code:
void Summarize(IEnumerable<Section> sections)
{
this.DateBegin = sections.Select(s => s.Date).Min();
this.DateEnd = sections.Select(s => s.Date).Max();
this.Income = sections.Where(s => s.IsIncome).Sum(r => r.Amount);
this.ExpenditureBank = sections.Where(s => s.IsExpenditureBank).Sum...
Hello, i have problem with linq2sql.
As you see below I have two tables from db - Dzieckos and Opiekuns. In Dzieckos i have idOpiekun. How to insert this idOpiekun like below, couse i have error in FK in example line.
protected void btDodaj_Click(object sender, EventArgs e)
{
DataClassesDataContext db = new DataClassesDataConte...
I'm working on a little side project. I've got a large SQL query expression, 30+ lines, that I wish to use in my project. This app needs to provide read-only access to the database through these queries.
There are so many data layer choices. nHibernate, Entity Framework, LINQ to SQL, Datasets, Castle ActiveRecord... others I can't na...
We're evaluating EF4 and my DBA says we must use the NOLOCK hint in all our SELECT statements. So I'm looking into how to make this happen when using EF4.
I've read the different ideas on how to make this happen in EF4, but all seem like a work around and not sanctioned by Microsoft or EF4. What is the "official Microsoft" response to...
Given the following two cases, which one is preferable (If they're both bad, doing it a completely different way is an option too)?
Convert.ToInt32 called in Where:
var items = GetItems();
if (aDropDownList.SelectedIndex > 0)
{
items = items.Where(x =>
x.IntProperty == Convert.ToInt32(aDropDownList.SelectedValue)...
In both of the statement I am trying to fetch the ID of Catagory which has the name as specified in the variable;
both work fine. What is the difference and which one is better
string name = "Progreammers";
var categoryID = from c in DataContext.Categories
where c.Name == name
...
There were times when we had to choose between 2 or 3 technologies/strategies to develop modules.
Now for every small or large component/module/project, we have almost uncountable options. It might be easy for those with years of experience, but not for those who are new to programming, say less than a year.
I get frustrated sometimes ...
I'm pretty new to LINQ and a lot of modern data-driven application design techniques in general, so this may be a pretty basic question.
I'm trying to create a projection of a couple different Entity Framework entities to a simple presentation model. Let's say I have the entites Parent (properties are ID, Name, Age) and Child (propertie...
I have array number = {2,3,4,5,6}
Now i have to select rows from table "dtlRecord" where this number is a column.
Number count
2 10
3 23
4 20
So what i need is
select sum(count) from dtlRecord where number in (2,3,4,5,6) group by number
I need above query in LINQ to SQL
...
I have the following query in LINQ. "Symbol" doesn't exist, and the query is null, but I got an error, of casting and the program crashes.
decimal x = from cie in m_entities.Cie
where cie.symbol.Equals(Symbol)
select cie.cie_id;
Or can I have a null in x?
...
I have a class, Deck, that contains a method called Shuffle.
I'm working on refactoring Deck to extend List<Card>, rather than having List<Card> Cards as a property. However, while Cards.OrderBy (a => Guid.NewGuid ()) worked, OrderBy (a => Guid.NewGuid ()) does not:
Error CS0103: The name 'OrderBy' does not exist in the current context...
I have several installations of my Linq-to-Sql app running in the field. Now I've created a new version, which adds a new column to a certain table. I've added this column in the dbml file. But when updating the installation, I want to preserve the existing database. How to handle this? Linq-to-SQL doesn't seem to like this inconsistency...
In my LINQ to SQL setup I have various tables which are mapped to classes which basically support the same interface to support versioning, i.e.
public interface IValid
{
int? validTo { get; }
int validFrom { get; }
}
The LINQ to SQL classes derive from this interface like this:
public partial class representationRevision : I...
Is is possible to turn a dateOfBirth in a linq query to an age within the query so i can do a comparison to an int?
Cheers in advanced
Truez
...
For Typed Xml to Linq processing ,do i need to download Linq to XSD alpha installer or is it available in VS 2008 ? (I am using VS 2008 Professional edition).
...