I am trying to save a LINQ XML document using a StreamWriter. Using the following code works fine when the document is small (~6kb on disk) but doesn't work when the file is larger (~66kb on disk). If I replace the relative path with an absolute path it works fine in both situations. Is there any reason why the relative path should fail ...
How can I add unique constraint on a column using DBML in Linq as we are using DBML to create database ?
...
How have I to implement IEqualityComparer<DataRow> to remove duplicates rows from a DataTable with next structure:
ID primary key, col_1, col_2, col_3, col_4
The default comparer doesn't work because each row has it's own, unique primary key.
How to implement IEqualityComparer<DataRow> that will skip primary key and compare only data...
Sorry for the weird caption. What I'm trying to achieve is simple:
IEnumerable<IEnumerable<Foo>> listoflist;
IEnumerable<Foo> combined = listoflist.CombineStuff();
Example:
{{0, 1}, {2, 3}} => {0, 1, 2, 3}
I'm positive there is a Linq expression for this...
Sidenote: The lists may be large.
...
Okay guys, I have an asp.net website set up to target the 3.5 framework, using Linq to Sql. However, the site won't build, and i get missing namespace and assembly exception whenever i try to.
Here's the catch, I have installed 3.5 SP1, and I have added the System.Core, System.Data.Linq, System.Xml.Linq, and System.Data.DataSetExtensio...
I have daily records of production per category, i.e. category A: 80 tons. Each report row will look like this:
Daily Week to Date Month to Date
Actual Plan Var Actual Plan Var Actual Plan Var
Category A 100 110 -10 230 300 -70 900 1200 -30...
How would you refactor this code, with respect to the LINQ? I'm new to LINQ and haven't quite have a good handle on more complex queries (nested, grouping).
Can all of these three statements and foreach loop been converted into one LINQ statement?
void AddSeries(Series series, int phraseId)
{
using (var db = Database.Instance)
...
Just a quick one really, I'm just looking for a bit of clarification.
I'm looking to update multiple tables from one "Create" action, before I try it, I was just wondering if it's possible to simply just do the following:
db.hdCalls.InsertOnSubmit(a)
db.hdCustomers.InsertOnSubmit(b)
db.hdAssign.InsertOnSubmit(c)
db.SubmitChanges()
Or...
I have the following XML that uses the name “Part” in multiple locations. I just want to access the first level elements called “Part” and not for my Linq expression to also pickup the child elements called “Part”. I’ve used the following Linq to accomplish what I want but it seems a bit messy. Can it be improved ?
<Stuff>
<Parts>
...
Is there some way to get a distinct list of file extensions on all drives in my system?
...
Hi,
I am new to LINQ to SQL.... I need to add a new column to an existing table and I updated the dbml to include this new field. Then in my C# code, I query the database and accessing this new field. Everything is fine with the new database; however, if I load back a previous database without this new field, my program would crash wh...
I'm building a small project with SubSonic 3.0.0.3 ActiveRecord and I'm running into an issue I can't seem to get past.
Here is the LINQ query:
var result = from r in Release.All()
let i = Install.All().Count(x => x.ReleaseId == r.Id)
where r.ProductId == productId
select new ReleaseInfo
...
Hi,
I am having this For each loop
foreach (Account acct in acctTest)
{
if (acct.AccountId == acctId)
{
foreach (Customer cust in acct.CustomerColl)
{
if (cust.CustomerId == custId)
{
...
I am changing string array into dictionary collection.
string str = "When everybody is somebody then no one is anybody";
char[] separation = { ' ', '.', ',' };
var splitted=str.Split(separation);
(Absolutely it is not a good design,but i wish to know the logic)
When i build query
var i...
I have two string arrays ( I will not use it anywhere as it is not a good logic,this is for my learning purpose).
string[] names = new[] { "Joss", "Moss", "Kepler" };
string[] emails = new[] { "Moss@gmail", "Kepler@gmail", "Joss@gmail" };
How to use LINQ so as to make key value pairs like
{"Joss","Joss@gmail"} ,{"Moss","Moss@gmail"...
Having the following C# linq query:
var result =
from member in members
let BestPriceLength =
(from lumber in lumbers
where member.Thickness == lumber.Thickness && member.Width == lumber.Width && member.Length <= lumber.Length
select lumber).Min(l => l.Price / l.Length)
let BestLengthFromBestPrice = ??????
select ne...
In LINQ, is it possible to have conditional orderby sort order (ascending vs. descending).
Something like this (not valid code):
bool flag;
(from w in widgets
where w.Name.Contains("xyz")
orderby w.Id (flag ? ascending : descending)
select w)
...
I have a class Items with properties (Id, Name, Code, Price).
The List of Items is populated with duplicated items.
For ex.:
1 Item1 IT00001 $100
2 Item2 IT00002 $200
3 Item3 IT00003 $150
1 Item1 IT00001 $100
3 Item3 IT00003 $150...
I'm looking for an application to display what a linq expression would do, in particular regarding the usage of multiple access to the same list in a query.
Better yet, the tool would tell if the linq query is good.
...
select colId,
colTaskType,
MaxID
from tblTaskType
join (
select tblCheckList.colTaskTypeID,
max(colItemNumber) MaxID
from tblCheckList
group by colTaskTypeID
) x on coltaskTypeID = tblTaskType.colID
...