Seeing as though I've now solved all of my LINQ problems I'm not working on developing an actual model. The thing is with this is that I do not want to be tied in to a single technology, I want to have freedom to implement different data access technologies and work to a single interface.
Now, I've never done this before, but based on ...
This is a long shot, I know...
Let's say I have a collection
List<MyClass> objects;
and I want to run the same method on every object in the collection, with or without a return value. Before Linq I would have said:
List<ReturnType> results = new List<ReturnType>();
List<int> FormulaResults = new List<int>();
foreach (MyClass obj i...
In my application I build an XML file with this code using StringBuilder:
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine);
sb.Append(String.Format("<{0}>{1}", _pluralCamelNotation, Environment.NewLine));
for (int index = 0; index < 3; index++)
{
sb.Append(String....
I'm just starting with the Microsoft stack doing a web site in ASP.Net MVC and so far using LINQ to SQL. Should I consider LINQ to Entities? Does it have anything special to offer? If so, what?
...
I have a network folder which can contain up to 10,000 files (usually around 5000).
What is the fatest way I can get the filepath of the most recently created file in that folder using c#?
Currently I am using the below, but wondered if there was a quicker way.
Thanks.
DirectoryInfo di = new DirectoryInfo(xmlFileLocation);
var feedFi...
Hello!
Could someone please give an example of how to use ling to query over a long string of text and find a substring within that string?
regards
...
In our database, a file is "Processing" if the column "Pending" is set to false on the FileTable and that files FileID doesn't exist in the Transaction table.
How can I construct a LINQ query that basically says,
where f.Pending == False && (f.ID !=exist in db.Transactions.FileID)
The portion in the parenthesis is what I'm not sure ho...
I asked a previous question about mapping an enumerated value on a table using LinqToSql and the answer was to use the O/R Designer to set the type to global::MyNamespace.TMyEnum.
That works OK if your enumeration is based on an integer. But what if your enum is based on a string value? The most obvious application of this is:
public...
I have an odd sorting case I'm struggling to work out using LINQs GroupBy method.
I have two classes: Category and Item. Every Item has a category, and a Category can have a parent Category. What I need to do is organize all of the Items by their proper Category, but I also want to sort the Categories by the parent Category if there i...
I'd like to create a list of an anonymous type, for example:
Dim dsResource = New With {.Name = dsResourcesEnd(index).Last_Name & ", " & dsResourcesEnd(index).First_Name _
, .StartDate = dsResourcesStart(index).Day _
, .EndDate = dsResourcesEnd(index).Day}
I have created that ano...
Hi,
I am trying to craft a LINQ statement as follows:
The result should follow between two dates (today basically) OR
the result should have a "batchstatus" column that equals false (hasn't been verified yet)
the result should have a "ready" column that equals true (is ready to be verified).
So verifiers can see all data from today ...
how do I write the where statement that select records with Date field between sunday to saturday of a given date
Data Fields: Id, Name, Date
...
My repository returns a list of Accounts.
Each account has a date and a MoneySpent decimal amount. So, I have my list of Accounts and in my controller I'm trying to process this list a little.
I want to have an object which contains the string name of all the months in my Account list and a Sum of all money spent for that month.
Here...
Of these two options:
var result = from c in coll where c % 2 == 0 select c;
var result = coll.Where ( c => c % 2 == 0 );
Which is preferable?
Is there any advantage to using one over the other? To me the second one looks better, but I would like to hear other people's opinions.
...
Gday All,
I came across an interesting question today where I have two methods that, at a quick glance, both do the same thing. That is return an IEnumerable of Foo objects.
I have defined them below as List1 and List2:
public class Foo
{
public int ID { get; set; }
public bool Enabled { get; set;}
}
public static class Da...
I'm using the DataLoadOptions to retrieve the User that modified a Customer's details,
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Customer>(c => c.ModifiedBy);
However, I only want the User's ID and FirstName and not all the columns. Is there a way to specify the columns you want in the DataLoadOptions?
Tables:
Custo...
I have a Menu class that has a IQueryable property called WebPages. In the following statement I am returning Menu items based on a match but I need to include the Webpages property. Here is what I have at the moment.
var allCategories = Menu.All().Where(x => x.CategoryID == 4 && x.Visible)
I need to extend it to check a property in t...
Hi,
how to get a collection of all the leaves of a XElement tree regardless the hierarchy?
Thanks
...
I have an XML document as follows:
<Database>
<SMS>
<Number>"+447528349828"</Number>
<Date>"09/06/24</Date>
<Time>13:35:01"</Time>
<Message>"Stop"</Message>
</SMS>
<SMS>
<Number>"+447528349828"</Number>
<Date>"09/06/24</Date>
<Time>13:35:01"</Time>
<Message>"Stop"</Message>
</SMS>
</Database>
I am t...
Why does VB have more LINQ keywords than C#?
...