I'm new to using LINQ to Entities (or Entity Framework whatever they're calling it) and I'm writing a lot of code like this:
var item = (from InventoryItem item in db.Inventory
where item.ID == id
select item).First<InventoryItem>();
and then calling methods on that object like this:
var type = item.ItemTypeRe...
Profiling LINQ queries and their execution plans is especially important due to the crazy SQL that can sometimes be created.
I often find that I need to track a specific query and have a hard time finding in query analyzer. I often do this on a database which has a lot of running transactions (sometimes production server) - so just ope...
In my application I have several DataContexts that connects to different databases with different schemas. In a custom user control I display the results of the query and let the user edit them, and when the user edits the data I want to persist the changes to the database. To do that I need a reference to the source DataContext (or at l...
I have this query in LINQ to Entities.
var query = (from s in db.ForumStatsSet
where s.LogDate >= date1 && s.LogDate <= date2
group s by new { s.Topic.topicID, s.Topic.subject, s.Topic.Forum.forumName, s.Topic.datum, s.Topic.Forum.ForumGroup.name, s.Topic.Forum.forumID } into g
...
When ever I think I can use the yield keyword, I take a step back and look at how it will impact my project. I always end up returning a collection instead of yeilding because I feel the overhead of maintaining the state of the yeilding method doesn't buy me much. In almost all cases where I am returning a collection I feel that 90% of t...
The linq extension methods for ienumerable are very handy ... but not that useful if all you want to do is apply some computation to each item in the enumeration without returning anything. So I was wondering if perhaps I was just missing the right method, or if it truly doesn't exist as I'd rather use a built-in version if it's availab...
I have a collection of collections, all the child collections have the same number of elements. The parent collection does nothing other than hold the child collections.
[0] [Child_0] [ID: 1]
[0] [Child_0] [Amount: 4]
[0] [Child_1] [ID: 2]
[0] [Child_1] [Amount: 7]
[1] [Child_0] [ID: 1]
[1] [Child_0] [Amount: 2]
[1] [Child_1] [ID: 2]
[1...
I am new with Linq and I would like to sort some data that are in the BindinList. Once I did my Linq query, I need to use back the BindingList collection to bind my data.
var orderedList = //Here is linq query
return (BindingList<MyObject>)orderedList;
This compile but fail in execution, what is the trick?
...
Would someone explain how to get LINQ working with Sqlite.
...
Hi, I am saving some small images to Xml as a Byte[] via the following XElement construct..
XElement xe = new XElement("Images",
from c in qry
select new XElement("Image", new XAttribute("Date", c.Date),
new XElement("Data", c.Bytes)));
the Bytes property is a Byte[], looking at the resulting elem...
I have a DataTable that queries out something like below
usergroupid...userid......username
1.............1...........John
1.............2...........Lisa
2.............3...........Nathan
3.............4...........Tim
What I'm trying to do is write a LINQ statement that will return an array of UserGroup instances. The UserGroup class h...
Hi
I have a datammodel in linq to SQL that includes a type "Party" which is sub classed twice for "Company" and "Individual". I am trying to bind two repeaters to linq to sql queries as follows
Dim oComp As IEnumerable(Of Company)
Dim oInd As IEnumerable(Of Individual)
oComp = From oP As Company In ERM.Parties _
...
Hi,
Im wondering if its at all possible to create crosstab style results with Linq.
I have some data that looks like the following:
var list = new[]
{
new {GroupId = 1, Country = "UK", Value = 10},
new {GroupId = 1, Country = "FR", Value = 12},
new {GroupId = 1, Country = "US", Value = 18},
new {G...
I would like to be able to fusion an IEnumerable<IEnumerable<T>> into IEnumerable<T> (i.e. merge all individual collections into one). The Union operators only applies to two collections. Any idea?
...
I am creating a data source for reporting model (SQL Server Reporting Services).
The reports requires a lot of joins and calculations (let's say, calculating financial parameters like money spent on this, that, amount A vs amount B)...all this involves subobjects.
It makes a lot of sense to me to write unit tests for this code (i.e. wal...
Hi
I would like to return all rows from TableA table that does not exists in another table.
e.g. select bench_id from TableA where bench_id not in (select bench_id from TableB )
can you please help me write equivalent LINQ query. Here TableA source : Excel and TableB source : Database
I am loading Excel sheet data into DataTable ...
Hi,
I am new to LINQ. I am trying to find the rows that does not exists in the second data table.
report_list and benchmark both type are : DataTable. Both these datatables are being populated using OleDbCommand,OleDbDataAdapter. I am getting an error "Specified cast is not valid." in foreach ... loop. I would appreciate your help.
...
How can I ignore accents (like ´, `, ~) in queries made to a SQL Server database using LINQ to SQL?
UPDATE:
Still haven't figured out how to do it in LINQ (or even if it's possible) but I managed to change the database to solve this issue.
Just had to change the collation on the fields I wanted to search on. The collation I had was:
SQ...
Short version:
Could anyone suggest or provide a sample in LINQ to XML for VB, or in an XSLT of how to change one XML element into another (without hardcoding an element-by-element copy of all the unchanged elements)?
Background:
I have an XML file, that I think is properly formed, that contains a root entry that is <collection> and ...
is there any way to retrieve mapping table name for an Entity in Entity-framework in program? I know you can use .ToTraceString() to get the command text and then extract the table name, but ToTraceString() method is very slow. is there any other way like using ObjectContext.MetadataWorkspace?
Thanks
...