I'm having a hard time getting the LINQ-syntax.. How can I do this command in a better way?
var user = (from u in context.users
where u.email.Equals(email)
select u).Single();
var pinToUser = (from ptu in context.pintousers
where ptu.user_id.Equals(user.id)
select ptu).Single();
...
Hi,
Im using LinqDataSource like that:
<asp:LinqDataSource ID="LinqDataSource3" runat="server" OnSelecting="LinqDataSource3_OnSelecting">
</asp:LinqDataSource>
And I have ASPxGridView
<dxwgv:ASPxGridView ID="ASPxGridView2" ClientInstanceName="ASPxGridView2Client"
runat="server" AutoGenerateC...
I got a linq query time out exception. After a bit search online, using TransactionScope to make it 'nolock' gets my vote. However, after using the below code, i still get the same time out exception. Any help is appraicated, thanks in advance.
IEnumerable<IGrouping<string, Log>> grps = logs.GroupBy(l => l.msg_shortdesc);
using (var t =...
I'm building a list of properties of a type to include in an export of a collection of that type. I'd like to do this without using strings for property names. Only certain properties of the type are to be included in the list. I'd like to do something like:
exportPropertyList<JobCard>.Add(jc => jc.CompletionDate, "Date of Completion...
I have an IEnumerable of an item class defined like this:
public class Item {
public DateTime Date { get; private set; }
public decimal? Value { get; private set; }
public Item(DateTime date, decimal? value) {
Date = date;
Value = value;
}
}
These items are in a specific time interval (5 minutes for exemple)...
What is the most efficient way to find a sequence within a IEnumerable using Linq
I want to be able to create an extension method which allows the following call:
int startIndex = largeSequence.FindSequence(subSequence)
The match must be adjacent and in order.
...
Hi Guys,
Trying to make a really simple repository and service layer pattern here. (.NET 4, C#, LINQ, although this question is partially language-agnostic). Note: this is just R&D.
My goal is to minimize the amount of method definitions in my service layer.
Here's my Repository Contract:
interface IFooRepository
{
IEnumerable<Foo...
I am using LINQ for paging data in my website. I am currently using Skip() and Take() to perform the paging. Now I want to cache the data using cache dependencies so that the the cache will invalidate if the data changes. However SQL Server's query notifications don't support the TOP expression. Are there any alternative ways to query a ...
Hello – I’m trying to get a where condition to apply to a sub collection. I can get the criteria to return the proper parents. However, I want the sub collection to be limited to the criteria as well.
In my example code, I only want people with “LINK” skills; also, I only want the skills for each person to equal “LINK.” That is, each ...
I am having a problem converting a value to int.
I ran this query to count number of tags in xml file
var items = (from category in xml.Descendants("category")
where category.Attribute("id").Value != "0"
select category).Count();
it is returning me this 0x00000002 when i am expecting...
I have a string list(A) of individualProfileId's (GUID) that can be in any order(used for displaying personal profiles in a specific order based on user input) which is stored as a string due to it being part of the cms functionality.
I also have an asp c# Repeater that uses a LinqDataSource to query against the individual table. This r...
I have a collection IEnumerable. In a LINQ query, preferably, I would like to select only the properties in this collection from type T, into an anonymous type, where T is a POCO business object.
Example:
My IEnumerable contains properties "Name", "Age".
My POCO is:
public class Person
{
public string Name { get; set; }
publ...
part of the code:
Dictionary<Calculation, List<PropertyValue>> result = new Dictionary<Calculation, List<PropertyValue>>();
while (reader != null && reader.Read()) //it loops about 60000, and it will be bigger
{
#region create calc and propvalue variables
//...
#endregion
//this FirstOrDefault needs a lot of time
tm...
Hello
I wanna add a Test (common) attribute to all my XML files. So that I could use it as a common attribute when I wanna test them.
I tried CreateAttribute but Linq dosen't recognize it
I tried "xElement.Add(new XAttribute("Test", value));" but it also didn't work
Any Suggestions?
Thanks
Here for example is a code
public void...
How to make this expression using the methods of exptension, but (!) not using anonymous types?
from p in posts
join u in context.oxite_Users on p.CreatorUserID equals u.UserID
join pa in context.oxite_PostAreaRelationships on p.PostID equals pa.PostID
join a in context.oxite_Areas on pa.Area...
I have a T-SQL 2005 query which returns:
pid propertyid displayname value
----------- ----------- --------------- ---------------
14270790 74 Low Price 1.3614
14270790 75 High Price 0
14270791 74 Low Price 1.3525
14270791 75 High Price 0
14270792 74 ...
Acting on the answer to my Select a model property using a lambda and not a string property name question, wanting to add properties to a collection as follows:
var props = new ExportPropertyInfoCollection<JobCard>();
props.Include(model => model.BusinessInstallNumber).Title("Install No").Width(64).KeepZeroPadding(true);
props.Include(...
I have an IEnumerable and I want to get a new IEnumerable containing every nth element.
Can this be done in Linq?
...
string output = (from s in abc.longs
group s by DateTime.FromFileTimeUtc(s).Minutes < 1
.... // so on so forth
The question I have, is I do "DateTime.FromFileTimeUtc(s) like 10 times here, is there any way to do
from s in abc.longs
t = DateTime.FromFileTimeUtc(s).Minutes
group by t < 1
...
I'm trying to do this:
var collection1 = new Collection<string> {"one", "two"};
var collection2 = new Collection<string> {"three", "four"};
var result = collection1.Concat(collection2);
But the result variable is type Enumerable[System.String]
, whereas I want a Collection[System.String]
I've tried casting:
var all = (Collection<st...