This is not another question about 'How Can I Sort Dynamically (based on an arbitrary user provided field)?'
The question is -- how can I change sort order when I know the potential sorts in advance? (And thus avoid reflection / custom Expression building typically associated with truly dynamic sorting.)
Take for instance this subquery...
Is this the proper way to accomplish joining 3 (or more) tables with LINQ (to SQL)? Especially the select portion. Am I on the right track to return a single record(row) of data that spans across the tables?
public static DataTable GetCurrentEmploymentQuestionnaire(Guid employmentQuestionnaireID)
{
var Questionnair...
Greetings:
In VB.NET, let's assume I have the following Structure:
Public Structure Product
Public ItemNo As Int32
Public Description As String
Public Cost As Decimal
End Structure
... and a Generic List of the Products:
Dim ProductsList As New List(Of Product)
Dim product1 As New Product
With product1
.ItemNo = 10...
I have a non-trivial Linq To Sql query that I'm trying to break down into pieces for the sake of readability / further filtering / reuse.
The refactored code looks like this, where ids is the subquery performed to grab the ids.
var results = from solution in context.csExtendedQAIncident_Docs
join solutionText in contex...
Can anyone point out some good LINQ training resources. Mostly interested in getting some developers that are very skilled with SQL up to speed using Lambda and LINQ queries. They are struggling with some of their more advanced queries and fall back on ExecuteQuery() to kind of do the LINQ thing. Queries that used to be easy in TSQL but ...
Hello all,
Definitely a LINQ newbie, but very experienced with SQL and C# and wondering if this is possible in LINQ. If so, I could use it other places, but I figured this would be a good starting point (and help to simplify/clean up some code). This could be more generalized, but I figured this might be a good real-life example that co...
I have a list of rows like this (NULLs since i'm using DefaultIfEmpty)
Vol Component Dwg View Revision
Volume U01 Composed Drawings SJTest 1 B
Volume U01 Composed Drawings SJTest 1 A
Volume U01 Composed Drawings SJTest 1 NULL
Volume U03 Composed Drawings SJTest2 2 NULL
I want to sort by the last coln,...
Hi Gurus,
I am trying to figure out if I can use LINQ to provide me with the distinct values of some data I have in a DataTable (FirstName, LastName, QTY). I can get the distinct values and fill my List, but I have to run two different LINQ queries to get it....I am sure there is a better way to do it :)
Any suggestions would be great...
I am a Database guy and dotnet novice who needs help with below UseCase
I am using LINQ to populate the DB but I am not sure how to insert/update ActiveDirectory using LINQ any sample code for doing that.
Most code samples on Google show how to query ActiveDirectory but not CRUD operations
...
In my table I am having my client Id as
Actual Input:-
<client>
<ClientId>421</ClientId>
<Amount>100</Amount>
<client>
<client>
<ClientId>426</ClientId>
<Amount>200</Amount>
<client>
<client>
<ClientId>421</ClientId>
<Amount>300</Amount>
<client>
<client>
<ClientId>427</ClientId>
<Amount>400</Amount>
<c...
Hello all, I am creating a gridview that will be populated based upon a linq statement, the sql is as follows:
SELECT TOP 10 IDDesc, UnitUserfield1, UnitUserfield2, ProductPercentage
FROM tblOnlineReportingCOMPLETEWeights
WHERE (MaterialLevel = 'Primary') AND (MaterialText = 'Paper')
ORDER BY ProductPercentage DESC
Now...
I maintain a fairly complex infrastructure consisting of a number of setups like the following:
3rd party application server with its built-in database
3rd party unmanaged c++ API library which exposes methods to query and/or receive updates from the server; also contains data structure definitions
My managed wrapper for the library; e...
Hi.
I have a LINQ query which returns a set of rows. The structure is:
NAME, col1, col2, col3, col4
name1 1 null null null
name1 null 1 null null
name1 null null 1 1
As a result I want to have one row containing
name1 1 1 1 1
So I want to group those results by name and merge (sum?) th...
Me again!
I have a question re. inserting into a sql table using LINQ. I am essentially creating a feedback form whereby a user enters there details, hits submit and their data is inserted into a sql table.
I haven't got very far!!!
protected void btnSubmitFeedback_Click(object sender, EventArgs e)
{
ORFeedDataClassesDataContext...
i'm having to two tables, which i need to compare both the table.
Let say table 1) Student profile 2) staff list.-- in this each staff has their student id , like many row
I need to get the current staff who log in's student id which may be many row.
And the resulted student profile from table 1.
...
Hello.
I have downloaded and installed linq-to-sqlite from http://sqlite.phxsoftware.com/
But the following test code:
[ Table( Name = "items" ) ]
public class MyItem
{
[ Column( IsPrimaryKey = true ) ]
int MyId;
}
public class MyDb : DataContext
{
public MyDb( IDbConnection c ) : base( c ) {}
public Table< MyItem > myItems;
}...
I'd rather not use Linq if I don't have to (I remove references to it when I start a new project). Lambdas look useful, though. I'm not going to get in the habit of using lambdas, however, if Linq has to tag along for the ride.
Thanks in advance
...
Hi,
I'm fond of defensive programming.
I hate exception throwing, but this is not the subject of my question.
I adapted an extension to linQ to be able to perform an order by with a column name
public static IEnumerable<T> OrderBy<T>(this IEnumerable<T> list, string sortExpression)
With defensive programming, this method ret...
I encountered an interesting thing today that I have never noticed before. It appears that SQL and LINQ order AlphaNumeric strings differently.
Data table contains rows:
A
G
6
P
1
D
J
2
T
Z
9
F
0
If I perform an Order By in the SQL, I receive the following results:
A
D
F
G
J
P
T
Z
0
1
2
6
9
Now consider this LINQ sample:
class Progr...
Original
I don't get why the Where() clause doesn't give me the right results in the last example.
It isn't any different is it? Why does C# behaves differently?
transactions = IEnumerable<Transaction> //pseudocode
//This works: It gives me the transaction I need.
DateTime startDate = DateTime.Parse(parameter.Constraint);
transactio...