In my experience building web applications, I've always used a n-tier approach. A DAL that gets data from the db and populates the objects, and BLL that gets objects from the DAL and performs any business logic required on them, and the website that gets it's display data from the BLL.
I've recently started learning LINQ, and most of th...
public class Foo
{
public string Name { get; private set;} // <-- Because set is private,
}
void Main()
{
var bar = new Foo {Name = "baz"}; // <-- This doesn't compile
/*The property or indexer 'UserQuery.Foo.Name' cannot be used
in this context because the set accessor is inaccessible*/
using (DataContext dc = n...
Given two related tables (reports, report_fields) where there can be many report_fields entries for each reports entry, I need to allow the user to enter new report_fields, delete existing report_fields, and re-arrange the order.
Currently I am using a DetailsView to handle the editing of the reports. I added some logic to handle repor...
On page 64 of "LINQ To Objects Using C# 4.0" (Tony Magennis) he states that LINQ's quicksort ordering algorithm is unstable...
...although this is simply solved by
cascading the result into a ThenBy or
ThenByDescending operator.
Huh? Why would cascading an unstable sortation into another sortation fix the result? In fact, I'...
Hi
I have three level hierarchical data. using the statement below i managed to display two
level data. I need to extend it to one more level.
Current hierachy is Modules-->Documents
I need to extend it as Packages-->Modules-->Documents
var data = (from m in DataContext.SysModules
join d in DataContext.SysDocuments o...
I have the following information
var details = Details.Where(d => d.isActive);
I would like to query another table, Authorizations, that has a FK to Details, and get the sum amounts of the authorizations that are contained within the details object grouped by the detail and a FundCode.
Details (1 to many) Authorizations
Seems si...
Having the following:
var categories = new List<double> {10,20,30,40}; // Note the 40 here...
var bundleA = new List<double> {10,20};
var bundleB = new List<double> {20,20,30};
var lots = new List<List<double>> {bundleA, bundleB};
var total = lots.Sum (l => l.Count);
var res = from lot in lots
from bundle in lot
...
I have two arrays of doubles of the same size, containg X and Y values for some plots.
I need to create some kind of protection against Inf/NaN values. I need to find all that pairs of values (X, Y) for which both, X and Y are not Inf nor NaN
If I have one array, I can do it using lambdas:
var filteredValues = someValues.Where(d=> !(d...
I once read a blog post and cannot find it anymore. drat!
It was about a guy who setup a wcf service (I guess RIA, but could have been something else) exposing the model via IQueryable to the querystring.
Sou you could say
http://host/articles/123/ratings
and you'd get a list (soap or json) of serialized Rating entities (the properti...
I have two collections of strings: CollectionA is a StringCollection property of an object stored in the system, while CollectionB is a List generated at runtime. CollectionA needs to be updated to match CollectionB if there are any differences. So I devised what I expected to be a simple LINQ method to perform the removal.
var strDiffe...
The Compare method in Linq lets you find by an IEqualityComparer, but I can't find a counterpart method that allows you retrieve an item by the same comparer.
Is this really the best way to do it?
MyItem myFinderItem = new MyItem(keyField1, keyField2);
if (myList.Contains(myFinderItem, new MyEqualityComparer()))
{
MyItem myRealItem...
I have the following view:-
CREATE VIEW tbl_adjudicator_result_view
AS
SELECT a.adjudicator_id, sar.section_adjudicator_role_id, s.section_id, sdr.section_dance_role_id, d.dance_id, c.contact_id,
ro.round_id, r.result_id, c.title, c.first_name, c.last_name, d.name, r.value, ro.type
FROM tbl_adjudicator a
INNER JOIN tbl_section_adjudica...
Evidently LINQ's "OrderBy" had originally been specified as unstable, but by the time of Orca it was specified as stable. Not all documentation has been updated accordingly - consider these links:
Jon Skeet on OrderBy stability
Troy Magennis on OrderBy stability
But if LINQ's OrderBy is now "stable," then it means it is not using a ...
Hello guys
does anyone know how to convert this SQL statement to a LINQ to a List?
SELECT TOP(5) COUNT(Tickets.CategoryId), Categories.CategoryName
FROM Tickets
INNER JOIN Categories ON Tickets.CategoryId = Categories.CategoryId
GROUP BY Categories.CategoryName
ORDER BY 1 DESC
The result would be something like this?
public static ...
Given a list...
class Item
{
public Name
{
get;
set;
}
}
List<Item> items = new List<Item>
{
new Item() { Name = "Item 1" },
new Item() { Name = "Item 1" },
new Item() { Name = "Item 2" },
new Item() { Name = "Item 3" }
}
List<Item> listing = new List<Item>
{
new Item() { Name = "Item 1" },
new Item() { Name = "Item 2"...
This is similar to my last question; but from a different angle.
http://stackoverflow.com/questions/2792393/see-if-item-exists-once-in-enumerable-linq
Given the following set of items, and lists containing them...
Item 1
Item 2
Item 3
Item 4
Item 5
class Item
{
string Name { get; set; }
}
List<Item> available = new List<Item>()
{
I...
HI,
I am developing asp.net mvc site with linq-to-sql we are having 1000 cocurrent users and we are having performance problems.
I have found that stackovewflow is also build on linq-to-sql? So can anybody know how they improved performance.
Without line performance was good each page are loaded in 3 seconds but after migrating to lin...
I need a linq to entities query/ lambda expression for the following statement. Any help is greatly appreciated
SELECT
at.Name,
Count(a.AssetTypeId) as CountofAssets,
at.AssetTypeId
FROM
AssetTypes at, Assets a
WHERE
at.AssetClassId = 7
GROUP BY
at.Name,at.AssetTypeID
...
So here's the thing: I've got an app that I'm testing that uses LINQ to Entities (EF4/.NET4). The app binds to an implementation of the Contains method that ignores nulls and, due to the way the database is configured, ignores case. That works great.
However, when I call into the same methods from my unit tests, I'm passing in a fake co...
I am a bit new to LINQ, here is my problem.
I have a List of List of Items
I like to get the Items which are present in
only one List (and if I could get the
List in which they are without
re-iterating through the "list of
list" that would be great).
I am trying without success to use the Aggregate / Except / Group keywords in the L...