I have a T-SQL query which populates a DataSet from an MSSQL database.
string qry = "SELECT * FROM EvnLog AS E
WHERE TimeDate =
(SELECT MAX(TimeDate)
From EvnLog
WHERE Code = E.Code)
AND (Event = 8)
AND (TimeDate BETWEEN '" + Start + "' AND '" + Finish + "')"
The database is...
From a List of builtAgents I need all items with OptimPriority == 1 and only 5 items with OptimPriority == 0. I do this with two seperate queries but I wonder if I could make this with only one query.
IEnumerable<Agent> priorityAgents =
from pri in builtAgents where pri.OptimPriority == 1 select pri;
IEnumerable<Agent> otherAgents =
(...
In a vb.net application I have a set of integers currently stored in multiple Arraylist (But this could be something different if required)
al1 = {1, 2, 3, 6, 7, 9}
al2 = {2, 3, 4, 9}
al3 = {2, 3, 19}
I would like to get the set {2, 3}
I thought about using LINQ to join the list, but the number of Arraylist can change. Im open to any ...
I have a situation where I am providing a method to query for data in various ways. We provide the user with 4 different fitler criteria and they can mix and match as much as they want.
For example:
public Fruit GetFruit(Boolean isLocal, string storeName, string classificationType, string state);
This is simple when all of the attr...
I have the below LINQ method that I use to create the empty EmploymentPLan. After that I simply UPDATE. For some reason this works perfectly for myself but for my users they are getting the following error -->
The target table 'dbo.tblEmploymentPrevocServices' of the DML statement cannot have any enabled triggers if the statement cont...
I have the following List which contains the following collection.
How i can transform this with linq so that i get nested items.
var categories = new List<Category>(); // id, parentId, name
categories.Add(1, 0, "Sport");
categories.Add(2, 0, "Pets");
categories.Add(3, 1, "Foot ball");
categories.Add(...
What is the best what to handle carriage returns in xml formatting with xml?
<myxml>
<mydata>
</mydata>
</myxml>
<myxml><mydata></mydata></myxml>
...
Hey Guys-
I am using LINQKit on mosso and am getting an Security Exception about it not being able to run in medium trust.
As anyone ran LINQKit in medium trust and been successful?
Thanks!
...
I have two database tables, one for Users of a web site, containing the fields "UserID", "Name" and the foreign key "PageID". And the other with the fields "PageID" (here the primary key), and "Url".
I want to be able to show the data in a gridview with data from both tables, and I'd like to do it with databinding in the aspx page.
I'm...
Before you ignore / vote-to-close this question, I consider this a valid question to ask because code clarity is an important topic of discussion, it's essential to writing maintainable code and I would greatly appreciate answers from those who have come across this before.
I've recently run into this problem, LINQ queries can get prett...
OK, so this is the strangest issue in .net programming I have ever seen. It seems that object fields are serialized in .net web services in order of field initialization.
It all started with Flex not accepting SOAP response from .net web service. I have found out that it was due to the order of serialized fields was statisfying the orde...
I need to calculate a whole bunch of averages on an List of Surveys. The surveys have lots of properties that are int and double valued. I am creating a business object to handle all the calculations (there are like 100) and I'd rather not code 100 different methods for finding the average for a particular property.
I'd like to be abl...
I have two tables:
Messages - Amongst other things, has a to_id and a from_id field.
People - Has a corresponding person_id
I am trying to figure out how to do the following in a single linq query:
Give me all messages that have been sent to and from person x (idself).
I had a couple of cracks at this.
Not quite right
MsgPeople ...
I am new to database programming, so I'd like help getting on the right track. I have read that there are Microsoft-defined and third-party data providers for data access. MSDN has information on data providers for SQL Server, OLE DB, ODBC, Oracle, as well as the EntityClient provider (Entity Framework).
Which data provider is today's ...
Hi,
I have the following LINQ example:
var colorDistribution =
from product in ctx.Products
group product by product.Color
into productColors
select
new
{
Color = productColors.Key,
Count = productColors.Count()
};
All this works and makes perfect sense.
What I'm trying to achieve is...
OK, so this is the strangest issue in .net programming I have ever seen. It seems that object fields are serialized in .net web services in order of field initialization.
It all started with Flex not accepting SOAP response from .net web service. I have found out that it was due to the order of serialized fields was statisfying the orde...
Hi everybody, I'm using Linq To Nhibernate, and with a HQL statement I can do something like this:
string hql = "from Entity e order by rand()";
Andi t will be ordered so random, and I'd link to know How can I do the same statement with Linq to Nhibernate ?
I try this:
var result = from e in Session.Linq<Entity>
orderb...
I know I can map two object types with LINQ using a projection as so:
var destModel = from m in sourceModel
select new DestModelType {A = m.A, C = m.C, E = m.E}
where
class SourceModelType
{
string A {get; set;}
string B {get; set;}
string C {get; set;}
string D {get; set;}
string E {get; set;}
}
c...
Hey, I'm very new to linq and lamba expressions. I'm trying to walk a collection, and when I find an item that meets some criteria I'd like to add that to another separate collection.
My linq to walk the collection looks like this (this works fine):
From i as MyCustomItem In MyCustomItemCollection Where i.Type = "SomeType" Select i
I...
I have 2 arrays named Arr1 and Arr2 in C#.
They are of the exact same dimensions...
I need to get the element of Arr1 corresponding to maximum of elements in Arr2 beginning with given indices ...
e.g
Get indices of the max of Arr2 [ 1 , 10 , 3 , i , j ] for all i,j
Return Arr1 [ 1 , 10 , 3 , i , j ]
Of course I need the elegant sol...