Hi. I think a lot of people have had this issue but I'm not able to fix it or understand why I'm having it. I've been tearing hair out for a couple of hours now.
I'm getting the error, "Object reference not set to an instance of an object." on my datacontext.SubmitChanges() on the SECOND time this method runs (I'm looping through a ...
As far as performance is concerned,
Which way is better Linq Select Query or For Loop to search something in generic List?
...
I am going to be performing an XSLT transformation, transforming XML to an HTML table. It's tabular data, so that's why I'm not using div's. ;)
Anyway, I need to repeat one part of the XSLT for the size of one of my collections. Here's a snippet of the code...
Dim styleSheet = <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet ver...
Hi there,
Trying something with Linq / Lambda's, but have no idea where to search.
I'm working on some simple sorting in an ASP.net GridView. Here's some sample code:
IQueryable<User> query = (from c in users select c).AsQueryable<User>();
if (isAscending)
{
switch (e.SortExpression)
{
case "Name":
query.O...
hi . i have a datatable where i need to filter the record based on the condition.
i know we can do it by using dataview filer condition.
is there any way we can use linq syntax filter the data table base on condition?
thank you
...
I am trying to load data from XML string into a structure of some sort so once loaded I can then say Data.PropertyName to read the values.
Is the below code the most optimal way of loading the data into the structure?
Obviously calling First() has a memory hit so if you have elements with sub elements will calling First() for each ...
hi
how to convert this sql query to linq query? in asp.net
SELECT distinct P.Pid,P.Name,PC.categoryName,
(select count(id) from POrderdetails where id=p.Pid)as detailsCount
FROM PTable P INNER JOIN PCATEGORY PC ON PC.pcategoryId=P.pCategoryId
ORDER BY detailsCount desc
...
I am having a info class with following field like id,name,address and i have created list of that info like List.
I want to have all the values of list into comma seperated strings using linq. Is there any way for this.
...
Imagine the following list:
List<List<List<String>>> listRoot = new List<List<List<String>>>();
I want to count the elements of the first and the second list and return the accumulated value:
int iFirstListCounter = 0;
int iSecondListCounter = 0;
foreach (List<List<String>> listFirst in listRoot)
{
iFirstLis...
This one was inspired by my language-guru co-worker who can't seem to find a good use for them, and after a few lame attempts of my own, I'd have to agree.
Now I know these concepts tend to flow a lot more easily once you get some good practical reasons down.
At the moment it seems as though its only purpose is to allow you to write...
I have two XMLDocuments that contain some similar information but there are other nodes that contain different information between the two.
I am using XMLSerialization to put my data into a structure as shown here
I know you can merge XML files by using a DataSet as shown here but I want to somehow serialize the first document I see in...
Imagine I have 2 tables in my database, with the same schema (columns, types, etc). Can Linq-To-Sql treat them as Table<AClass> using the same class for both of them? How to do it?
...
What exactly does a LINQ function return when there are no matches? Take the Where method, for example:
var numbers = Enumerable.Range(1, 10);
var results = numbers.Where(n => n == 50);
What would be in results at this point?
...
Hello Friends,
I am a beginner with LINQ and lambda function's. I was wondering how can i convert multiple linq statement to one statement using selectmany function.
string viewname = (from a in StoredProcedureParameters.Tables[0].AsEnumerable()
where a.Field<string>("ViewName") == displayName
select a...
I have the below LINQ method which gets called from a User Control and dumped straight to a standard DataGridView. My users want it default sorted, first, by DisenrollmentDate and then, Member Name. Right now, with the code below, it sorts by DisenrollmentDate ONLY.
BLLCmo.cs
public static DataTable GetAllMembers(Guid workerID)...
Hi,
I am developing an application with RIA Services, and in my DomainService class, I have all that standard functions generated by the RIA for general CRUD operations. The problem is that I tryed to create my own function that insted of listing all the the 45 columns in the Select statment, would list only 2 (NOM and PRENOM) and also ...
This is a follow up from here -->multiple-sorting-on-linq-nested-method .
Basically, on let memberName = ... it is throwing this exception Method 'System.String MemberName(Int32)' has no supported translation to SQL. and I am not figuring out the solution.
Also, BLLCmo and BLLConnect actually use TWO different DataBases. The original ...
Seems like I may have missed something simple in the syntax, but I'd like to get the results of FirstOrDefault from a linq statement directly without having to store the IEnumerable in a temporary variable first. Something like this:
var bestCar = from c in cars
orderby c.Price
select first c
I know the fir...
Is there a way to add custom linq keywords and tell the compiler how to translate them to actual extension methods?
For example, translate the single keyword:
var color = from c in colors
where c.IsFavorite
select single c
To
var color = colors.Where( c => c.IsFavorite ).SingleOrDefault();
...
I watched this Introduction to Moq video on Dimecasts.net. In the video, when the guy sets up his moq test, he has the following code:
[Test]
public void TestWithMock()
{
var mockEmailService = new Mock<IEmailService>();
mockEmailService.Expect(x =>
x.SendEmail(It.IsAny<string>,It.IsAny<string>)).Returns(true);
var ...