I have a table with a structure like this:
Column1 AS INT,
Column2 AS INT,
Column3 AS INT,
Column4 AS DECIMAL
My LINQ query is this:
var query = from t in context.Table select t;
I want to convert/transform the query to this Dictionary object:
Dictionary<int, Dictionary<int, Dictionary<int, decimal>>>
using only the ToDictionary...
I am new to database programming and want some tips on performance / best practices. I am parsing some websites to scrap television episode infos and placing them into an MS SQL 2008 R2 relational database.
Lets say i have a table filled with type Episode. When i start a new parsing, i generate a new list of Episodes. The thing is, ...
I'm trying to figure out how to add an enumeration to an object with Linq. For example:
Dim thingBlock = <Things>
<Thing Name="Ish">
<SmallThing>Jibber</SmallThing>
<SmallThing>Jabber</SmallThing>
</Thing>
<Thing Name="U...
There's no Sort() function for IList. Can someoene help me with this?
I want to sort my own IList.
Suppose this is my IList:
public class MyObject()
{
public int number { get; set; }
public string marker { get; set; }
}
How do I sort myobj using the marker string?
public void SortObject()
{
IList<MyObject> myobj = new List<MyObj...
I want to convert this LINQ code
var x = from nm in names
select MyClass.SomeMethod(nm).TrimStart(',');
foreach (var vv in x)
{
// I want to group and count different types of vv here
}
to use shorter syntax, one where they do x => x in LINQ. I also want to group and count 'vv' (there could be number of similar vv's)
...
Hello Guys.
I have customized collection for indexing reason, its an implement ion of Idicationary (non generic). This is used to hold string based key and object based value.
Now please pardon my ignorance, I have just came out of the cave.
I want use an adapter between, this is a linq adapter which should take linq queries and pe...
I'm guessing is very simple, but I'm learning MVC 2 right now and I'm stuck. I've got strongly typed view with some fields and buttons which should change something in database by click on them. So it is code
<% using (Html.BeginForm("UpVote", "Home",FormMethod.Post,new { linkId = link.LinkID }))
{%>
<input type="submit" val...
Is it possible to have compiler support to enforce the cleanup of data (XSS encoding)?
This question got me thinking about double encoding and the other times when encoding is needed. Seems like it would work great for Linq, but possibly I may need this feature in other scenarios as well.
http://stackoverflow.com/questions/3774776/mic...
I have a query in linqtosql that returns a LabelNumber:
var q = from list in db.Lists
select list.LabelNumber;
var q then becomes an IEnumerable<string> with elements like this:
{"1","2","2.A","2.B","3","3.A","3.B"}
I basically want to order the elements as they appear above, but I can't use the OrderBy(x=>x.LabelNumber) be...
I need some clarification. Are these two methods the same or different? I get a little bit confused about when the reference to an object passed in a parameter by value is updated and when a new one is created. I know if that assignment creates a new reference, but what about changing a property? Will both of these methods update the...
I have the following code which detects all the elements in a Silverlight application beneath a certain point
then filters them to be only those of a particular type - CardButton
IEnumerable<UIElement> elementsBeneathCursor =
VisualTreeHelper.FindElementsInHostCoordinates(new Point(xPosn, yPosn), Application.Current.Roo...
I am trying to group by an CarId field , and then within each group, I want to sort on a DateTimeStamp field descending. The desired data would be for each Car give me the latest DateTimeStamp and only that 1 in the group.
I can get to this point, but having problems taking the top 1 off of the group and ordering the group by DateTimeS...
Say I have an array of strings like this:
string [] foos = {
"abc",
"def",
"ghi"
};
I want a new collection that contains each string and its reverse. So the result should be:
"abc",
"cba",
"def",
"fed",
"ghi",
"ihg"
I could just iterate through the array, but this is pretty clumsy:
string Rever...
Ok, bear with me... hadn't done any Linq or Lambda until a couple of days ago :)
I'm using C# and the ADO.NET Entity Framework. I want to query my model and get back a List of objects based on a relationship.
Here's my code:
var query = db.Achievements.Join
(
db.AchievementOrganisations,
ach => ach.AchievementId,
ao => ao.Achieve...
Possible Duplicate:
How to query an XDocument with LINQ when elements have a colon in their name?
I tried using XDocument to read a xml file that contains elements like this
<link:direct ...>
running the code
xml.Elements("link:direct")
gives me an error saying that I cannot use ':'
The ':' character, hexadecimal value ...
I'm trying to get the running total by using extension. And it is working now.
public static IEnumerable<TResult> Rollup<TSource, TKey, TResult>(
this IEnumerable<TSource> source,
Func<TSource, TKey> keySelector,
TResult seed,
Func<TSource, TResult, TResult> projection)
{
if (!source.Any()...
Hi,
I want to query a List<> and find out how MANY items match the selection criteria. using LINQ and c# /.net 3.5. How would I modify the query to return an int count.
var specialBook = from n in StoreDisplayTypeList
where n.DisplayType=="Special Book"
select n;
...
I have an collection of Videos who have a field typeidentifier that tells me if a video is a trailer, clip or interview.
I need to put them in 3 seperate collections.
var trailers = myMediaObject.Videos.Where(type => type.TypeIdentifier == 1);
var clips = myMediaObject.Videos.Where(type => type.TypeIdentifier == 2);
var interviews = my...
The below is my SQL query and want to be in LINQ. Can anybody help for this?
SELECT EmpId,Team,_Year FROM Plan
where EmpId in
(
select EmpId from master where 2150 in (immediatesupervisor,manager)
)
...
Hi All
I have the following method:
/// <summary>
/// Calculates the last trade date.
/// </summary>
/// <param name="tradesDictionary">The trades dictionary.</param>
/// <returns>The last trade date.</returns>
public DateTime CalculateLastTradeDate(ConcurrentDictionary<Guid, TradeRecord> tradesDictionary)
{...