I am trying to see if I can use LINQ to solve a problem I am having. I have a collection of items that contain an Enum (TypeCode) and a User object, and I need to flatten it out to show in a grid. It's hard to explain, so let me show a quick example.
Collection has items like so:
TypeCode | User
1 | Don Smith
1 | Mike Jones
1 | Jame...
i just graduated from a polytechnic where i was taught quite basic programming (at least in my opinion, like VB Calculators and such)
so now in my current job, i feel that that's not enuf. i am wondering from my basic foundation how can i build up my skills? i am picking up C# 3.0 (4.0 seems to be out soon) WPF, LINQ
the issue that i f...
I have a weird problem that sometimes when I make a change to a Linq object using the O/R designer (usually by adding a field that I've added in the DB), when I save the project, the designer.cs file gets deleted!
Fortunately I have my source control to fall back on; I undelete the file and back out the changes to the csproj file. But ...
I'm trying to generate an entity model from a Firebird database using the Entity Data Model Wizard, but it dies loading the data for the "Choose Your Database Objects" step with the error:
Microsoft Visual Studio
An error occurred while connecting to the
database. The database might be
unavailable. An exception of type
'Sy...
If a table has the adjacency model applied (ID,ParentID) how can the heirarchy be returned in Subsonic 3?
...
Consider a simple Edit/Update code:
public ActionResult Edit(int id)
{
return View(db.Foos.Single(x => x.Id == id));
}
public ActionResult Update(Foo changed)
{
Foo foo = db.Foos.Single(x => x.Id == changed.Id);
foo.P1 = changed.P1;
db.SubmitChanges();
}
What I am actually trying to do here is to send:
UPDATE [dbo].[...
I have what seems to be a fairly simple requirement, but looking around I'm not able to get a simple answer for this. I have looked on MSDN forums, Exper Exchange and nothing substantial was given to me. I have the following LINQ code
Dim SummaryLog As IQueryable(Of clPartCountSummary)
SummaryLog = From Inventory In db.tblPartCount...
What is the simplest way to programmatically toggle back and forth between test and dev databases using the LINQ to SQL ORM?
...
I would like to be able to pass in a Func<T, ?> that allows me to choose exactly how to sort a list of items... the issue I have is the the return type might vary... so for example I want to do something like this (not production code):
Func<POline, string> poLineOrder
if (option) poLineOrder = poline => poline.PartNumber;
else poLineO...
How would the following query look if I was using the extension method syntax?
var query = from c in checks
group c by string.Format("{0} - {1}", c.CustomerId, c.CustomerName)
into customerGroups
select new { Customer = customerGroups.Key, Payments = customerGroups }
...
I want an equivalent linq to object query for the below sql query
SELECT SUM(AMOUNT)
FROM ACCOUNTS a
INNER JOIN DETAIL d ON a.CODE = d.CODE
INNER JOIN ACCENTRIES e ON d.EID= e.EID and e.EDATE > '1/1/2000'
GROUP BY d.CODE
Thanks in advance
...
Imagine four lists, all at least have this Id string property, but may have other properties:
public class A //or B, C, D
{
public string Id { get; set; }
//..other properties
}
//so:
List<A> a1 = new List<A>();
List<B> a2 = new List<B>();
List<C> a3 = new List<C>();
List<D> a4 = new List<D>();
I want to select all DISTINCT...
I have an app I must write that will utilize a database for each company we are able to get as a client.
Unfortunately, the schemas for all the companies databases's are not identical, even though for this app they all have the basic information I need (even if their column names are different/in a different table).
My solution to ha...
Hi,
I have a XElement that maps like follows:
<book>
<author>sadfasdf</author>
<title>asdfasdf</title>
<year>1999</year>
</book>
<book>
<author>asdfasdf</author>
<title>asdfasdf</title>
<year>1888</year>
</book>
<book>
<author>asdfsdf</author>
<title>asdfasdf</title>
<year>1777</year>
</book>
How ca...
Hi,
the following linq statement returns a IOrderedEnumerable:
var list = from e in ritorno.Elements("dossier")
orderby e.Element("name")
select e;
How can i convert list to XElement?
Thanks
EDIT
list is IOrderedEnumerable<System.Xml.Linq.XElement>
...
Is it possible to sum hierarchical data using .NET's LINQ?
My data class looks like this:
class Node
{
public decimal Amount;
public IEnumerable<Node> Children { get; set; }
}
So I would have some data looks like this, but the tree could of course be arbitrarily deep.
var amounts = new Node
{
Amount = 10;
Children = ...
Hi,
I have a very simple application which currently has a single Linq to Sql class based on a single table.
I need to serialize (to XML) all rows in the table using the DataContext for the Linq To Sql class.
How do I go about doing this?
This is my current code :
var db = new MyEntityDataContext();
Stream fs = new FileStrea...
Not sure if this is called a lookup table... Here's a screenshot of the schema: http://apoads.com/db-schema.png
What I want to do is join the Ad and MilBase table where the MilBase.BaseID is a given value. In the result, I'd like to be able to access the data like so: ad.MilBase.BaseName, etc...
I just can't seem to wrap my mind around...
Hi,
I want to write a LINQ query which returns two streams of objects. In F# I would write a Seq expression which creates an IEnumerable of 2-tuples and then run Seq.unzip. What is the proper mechanism to do this in C# (on .NET 3.5)?
Cheers, Jurgen
...
I'm loading XML data into an object with this LINQ statement:
var smartFormFields = from smartFormField in xmlDoc.Descendants("smartFormField")
select new Models.SmartFormField
{
IdCode = smartFormField.Element("idCode").Value,
Label = smartF...