I assume I need to use the method call syntax instead of the query expression form, and I know the basics of grouping in the latter. Maybe some gurus can give caveats and advice on using group fields and aggregates obtained at runtime from a configuration, for use in a reporting like structure.
...
Using LINQ what is the best way to select a single item from a list if the item may not exists in the list?
I have come up with two solutions, neither of which I like. I use a where clause to select the list of items (which I know will only be one), I can then check the count and make a Single call on this list if count is one, the oth...
I've noticed that certain command cause LINQtoSQL to connect to the database and download the records that are part of the query, for example, .ToArray().
Does the command .Cast() cause a query to execute (and how can I tell these things in the future?). For example...
IRevision<T> current = context.GetTable(typeof(T))
.Cast<IRevis...
I have a DataContext (Linq to Sql) with over 100 tables, is it possible to get a list of all those tables and lets say print them to the console? This might be a silly question.
Thanks.
...
I want to use that and to be able to sort and edit records inside a gridview.
Is possible? How? Thanks!
...
lets say i have 2 tables: products (just product ID and name) and sales (sale ID, product ID, amount, date)
now, given a start date and end date, i want to sum for every product its total sales amount in the given time frame
notice that naturally some products will just have zero sales
how should i write this query?
...
I am using LINQ to XML. I want to use an equivalent of sql's <> operator in the where clause below....
var myBooks = from book in xDoc.Descendants("BOOKOB")
where book.Element("AUTHOR").Value
Please help!
...
I'm populating a datagrid using Linq--standard kind of stuff (code below). For some reason however my ultraDataGrid is stuck in some kind of read-only mode. I've checked all the grid properties I can think of. Is that a result of binding to a Linq data source? Anyone have example code of an updatable grid that uses Linq?
db = New Data...
Hi I am looking for best method for writing Dynamic LINQ query.
I have a function like
public IQueryable<Student> FindByAllStudents(int? id, string Name, int? CourseID, bool? IsActive) // like this way, all field values are passed
{
// code for compairision
return db.Student;
}
we can also write db.Student...
I want full text search facility in my previous question
For Example Name can be vikas patel.
And we pass Name as 'pat' that it should also give the above record.
Tell me aslo about date comparison like without specifying time it would give me all the similar date records.
...
Hi,
I want to update and insert some records based on a csv I read. The insert is not a problem, but how to update a bunch of data in a single statement? I have not clear how to join them.
Update Item
Set
Name = t.Name
From
Item i, TextFile t
Where
i.ItemNo = t.ItemNo
For the Name = t.Name I created an private Item UpdateItem(I...
Hello,
I'm having some problems updating the database using Linq...
Public Shared Function Save(ByRef appointment As MyLinq.Appointment, ByRef db As MyEntities) As Boolean
If appointment.id = 0 Then
db.AddToAppointments(appointment)
Else
db.AttachTo("Appointments", appointment)
'db....
Hi,
I am using this simple code to try and update a row
var MyDB = new SKN2DataContext();
var s_case = MyDB.SupportCases.FirstOrDefault(sc => sc.Id == 3);
s_case.OpenDate = DateTime.Now;
MyDB.SubmitChanges();
On the last line i am presented with the following exception
Value of member 'Id' of an object of
ty...
Hello!
I've been trying to insert row in the table having an identity column RequestID (which is primary key as well)
HelpdeskLog logEntry = new HelpdeskLog { RequestBody = message.Body };
if (attachment != null)
logEntry.Attachments = Helper.StreamToByteArray(attachment.ContentStream);
Database.HelpdeskLogs.InsertO...
I have two tables:
Topic (
TopicID: int, (primary key)
TopicName: varchar
);
Example (
ExampleID: int, (primary key)
TopicID: int, (foreign key to Topic table)
ExampleOrder: int,
ExampleName: varchar
);
Using Linq, given an ExampleID, I want to get the next example in the same topic (with the same TopicID). Here's how it ...
hi everyone
i am using asp.net and link to display a set of books from the db.
n it gives me an error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0118: 'int'...
I've got two tables that look like this:
I'm trying to generate query that includes two specific StatisticsNames for each period from ApplianceStatisticsLog. Below is the Linq query I have come up with. It works but generates a single query for the first sub-select, then one additional query for EACH record for the 2nd sub-select. Ouc...
I expected the following LINQ query to sort according to FirstName but the OrderBy extension method seems to have no effect.
DataClassesDataContext dc = new DataClassesDataContext();
var query = from contact in dc.Contacts
select contact;
query.OrderBy(c => c.FirstName);
Everything works fine when I include the orderby i...
I feel kinda stupid to even ask that question,
But i was sitting like an hour trying to figure out how to solve the problem.
I am currently making a project that uses ASP.NET and XML, for my project i created new web site from Visual Studio, and trying to keep my XML files in App_Data.
However when i trying to use code:
var topic = fro...
Is it possible to use a LINQ extension method within an ASP.NET databinding expression?
Within a GridView that is bound to a Customer collection which in-turn has a related Phones collection the following Eval expression fails:
<%# Eval("Phones.Single(p => p.PhoneTypeId == 2)") %>
The error message I receive is: 'First(p => p' is not...