I have an xml mapping file that looks something like this
<colourMappings>
<model name="modelX">
<mapping colour="White" configCode="1"></mapping>
<mapping colour="Aluminium" configCode="2"></mapping>
<mapping colour="Black" configCode="3"></mapping>
<mapping colour="Blue" configCode="4"></mapping>
...
I was interested in whether it would be faster to sort my classes using LINQ, or by implementing the IComparable interface and List.Sort. I was quite surprised when the LINQ code was faster.
To do the test, I made a very simple class with the not-so-apt name of TestSort, implementing IComparable.
class TestSort: IComparable<TestSort> ...
Given a datatable containing two columns like this:
Private Function CreateDataTable() As DataTable
Dim customerTable As New DataTable("Customers")
customerTable.Columns.Add(New DataColumn("Id", GetType(System.Int32)))
customerTable.Columns.Add(New DataColumn("Name", GetType(System.String)))
Dim row1 = customerTable.New...
I probably won't be able to explain this well enough, but here it goes...
I have a table similar to this:
Id | Foreign_Key_Id | A_Number | Some_Other_Info
1 1 100 Red
2 1 200 Blue
3 1 300 Orange
4 2 100 Green
5 2 ...
At work, we just upgraded from VS2005 to 2010. To this point, we've only used sprocs (I guess out of habit more than anything). I've been playing around with Linq (very simple tutorials - nothing major). As my first actual experience with an ORM, I like it.
In addition, I've only recently become familiar with the Enterprise Library bloc...
I currently have a View in MVC where I pass a single set of data to the view. However, I've come across a problem where I am having to use a LINQ query within a For Each loop in the View to pull out additional information from a SQL View of data from another DB.
The error I'm getting is Late binding operations cannot be converted to an ...
I am trying to build a dictionary from an enumerable, but I need an aggregator for all potentially duplicate keys. Using ToDictionary() directly was occasionally causing duplicate keys.
In this case, I have a bunch of time entries ({ DateTime Date, double Hours }), and if multiple time entries occur on the same day, I want the total ti...
I'm using the Dynamic.ParseLambda method from the Dynamic LINQ library to create expressions, compile each to a Func<>, and cache each in a dictionary:
// parse some dynamic expression using this ParseLambda sig:
Expression<Func<TArgument,TResult>> funcExpr =
System.Linq.Dynamic.ParseLambda<TArgument, TResult>(
expressionString, // ...
Had a problem in a complex linq query so I simplified it in LINQPad:
void Main()
{
List<basetype> items = new List<basetype>()
{
new typeA() { baseproperty = "1", extendedproperty = 1 },
new typeB() { baseproperty = "2", extendedproperty = 1.1 },
new typeA() { baseproperty = "3", extendedproperty = 1 },
...
i'm using Asp.net MVC with Sharp Architecture.
I have this code:
return _repositoryKeyWord.FindAll(x => x.Category.Id == idCAtegory)
.Take(50).ToList();
How can i order by random?
Note: i don't want to order the 50 extracted items, i want order before and then extract 50 items.
thks
...
I have a very dynamic SQL Server problem to solve. I am developing a tool that verifies matched data in multiple databases. [NOTE: the requirements on this project are pretty strict]
I need to make a C# tool that lets a user select any database from a dynamic list, then lets the user select a table (acting as a source db/table). Once th...
I have an entity with three columns, a, b, and c. If I project the ObjectSet to objects of an anonymous class:
var ret = e.foos.Select(x => new {
a = x.a,
b = x.b
}).ToList();
Then the actual SQL only includes the columns necessary to populate each object:
SELECT
[Extent1].[a] AS [a],
[Extent1].[b] AS [b]
FROM [dbo].[foo] ...
Hi,
I'm working on optimising the image retrieval from the database with LINQ.
The approximate image size is 4000 * 1000 pixels which weighs about 400-600KBs.
The images are retrieved through a controller which is being called by a webservice. Web service gets called through jQuery.
The first image that gets retrieved in about 0.7 - ...
I work on Northwind database
<dxwgv:ASPxGridView ID="ASPxGridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="LinqServerModeDataSource1"
KeyFieldName="CategoryID">
<Columns>
<dxwgv:GridViewCommandColumn VisibleIndex="0">
<EditButton Visible="True...
When I do a query that returns an anonymous type
var assets =
from Product p in Session.CreateLinq<Product>()
where bundles.Contains(p.ProductBundle)
select new {p.Asset, p.Asset.PropertyTbl};
Can I type the return to anything other than var?
...
I work on Northwind database.server MS2008.In linq i active a sp then show me the bellow error:
Syntax :
<dxwgv:ASPxGridView ID="ASPxGridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="LinqServerModeDataSource1"
KeyFieldName="CategoryID">
<Columns>
<dxwgv:GridViewCom...
Hi,
I am not very familiar with both LINQ to SQL and NHibernate.
As far as I understand LINQ to SQL is a kind of replacement of NHIbernate for .Net in many ways.
So does this mean that LINQ to SQL is a built-in replacament of NHibernate which let's a .Net developer to skip NHibernate and start to work with LINQ to SQL?
Thanks
...
Possible Duplicate:
Learning about LINQ
Hi everyone,
I just want to understand what exactly is LINQ in DOTNET? And How does it work?
Tx
...
I have a sql query that performs the type of select I'm after:
select * from Products p where p.ProductId in (
select distinct ProductId from ProductFacets
where ProductId in (select ProductId from ProductFacets where FacetTypeId = 1)
and ProductId in (select ProductId from ProductFacets where FacetTypeId = 4)
)
There can...
Hello: I am working on a C# project that reads an XML file and returns a list of lists. When I want to display a list I do this:
IEnumerable<Foo> myFooQuery = from t in myLists.SelectMany( l => l.bar)
orderby t.StartTime descending
select t;
dataGridView1.DataSource = myFooQuer...