C#: I have a collection of objects . T has 2 properties. Property A and Property B. The rule that this collection needs to adhere to is that the combination of values for A and B must be unique within the collection. In other words, A and B need to serve as a composite primary key.
Is there an operation in Linq I can use to check this c...
I know the method below isn't meant to work with any Entity, and its use shouldn't be enforced.
I found a System.Data.Linq.Table extension method which uses SqlBulkCopy to insert data. I am trying to adapt it to the Entity Framework but it throws a strange exception, while the original works for Linq-To-Sql data classes. I couldn't find...
In the past, I've written Linq to SQL queries that haven't performed well. Using SQL Profiler (or similar) I can look at how my query is translated to SQL by intercepting it at the database.
Is there a way to do this with Linq queries that operate solely on objects?
As an example, consider the following Linq query on a list of edges i...
I'm very new to Linq, I can find multi-line data reading examples everywhere (by using foreach()), but what is the correct way of reading a single line of data? Like a classic Product Detail page.
Below is what I tried:
var q = from c in db.Products
where c.ProductId == ProductId
select new { c.ProductName, c.ProductDescription...
I'm trying to come up with an elegant way to handle some generated polynomials. Here's the situation we'll focus on (exclusively) for this question:
order is a parameter in generating an nth order polynomial, where n:=order + 1.
i is an integer parameter in the range 0..n
The polynomial has zeros at x_j, where j = 1..n and j ≠ i (it sh...
So I've created a dbml in my project, which has three tables: Elements, ElementImages and Images. Every Element record could have multiple ElementImage records and each of those ElementImage records should have one Image record. The primary and foreign keys are all set up correctly and the associations are defined correctly as well. ...
Why is this thing giving the message in the second line (i.e. list convertion)?
IEnumerable<Order> MyQuery = from order in dataContext.GetTable<Order>()
where order.ID == 1
select new Order() {ID = order.ID, OrderDate=order.OrderDate };
List<Order> list = new List<Order>(M...
I have the following attributes applied to my linq to sql class:
[Document(MetadataType = typeof(SomeObjectMetadata))]
public partial class SomeObject
{
}
And this is the metadata code:
public class SomeObjectMetadata
{
[Field(FieldIndex.Tokenized, FieldStore.Yes, IsKey = true)]
private object ProductId { get; set; }
...
I'm quite new to LINQ and was wondering what was the best design for inserting an [Order], subsequently getting the [Order].[ID] and using this to save some [OrderItems].
The ID column of the [Order] table is an Identity column.
I want to try and prevent calling db.SubmitChanges(), getting the newly inserted Order ID and then having ...
I have a dictionary as follows:
IDictionary<string, string> dict;
How to create an enumerator that implements IDictionaryEnumerator (preferably using linq)?
...
Where are LINQ assemblies located in Windows XP?
...
I have a seemingly simple problem whereby I wish to reconcile two lists so that an 'old' master list is updated by a 'new' list containing updated elements. Elements are denoted by a key property. These are my requirements:
All elements in either list that have the same key results in an assignment of that element from the 'new' list...
I'd like to convert a DataTable to an IEnumerable<> of Dictionary<string, object>. I tried the following LINQ query,
from DataRow row in ds.Tables[0].AsEnumerable()
let rowDictionary = new Dictionary<string, object>()
from DataColumn column in row.Table.Columns.Cast<DataColumn>()
select rowDictionary.Add(column.ColumnName, row[column]...
I know in normal linq grammar, "orderby xxx descending" is very easy, but how do I do this in Lambda expression?
...
Hi there,
I`m new to Xpath and got a problem. I want all nodes under a specific parent-node!
I tried it with this query, but only get an empty result! :(
var ISDN_confs = from x in xdoc.XPathSelectedElements("//member[name='participantOne']//member[name='name']")
select x;
Sample XML:
<methodResponse>
<params>
<p...
I need help in turning this linq expression into a linq statment. SampleData.Publishers and SampleData.Books are simple collections that I have from the Linq in Action book.
Here is the expression
var pubBooks =
from pub in SampleData.Publishers
join book in SampleData.Books on pub.Name equals book.Publisher.Nam...
So I'm new to linq so be warned what I'm doing may be completely stupid!
I've got a table of caseStudies and a table of Services with a many to many relasionship
the case studies already exist and I'm trying to insert a service whilst linking some case studies that already exist to it. I was presuming something like this would work?
...
I have a Dictionary<string, string>.
I need to look within that dictionary to see if a value exists based on input from somewhere else and if it exists remove it.
ContainsValue just says true/false and not the index or key of that item.
Help!
Thanks
EDIT: Just found this - what do you think?
var key = (from k in dic where string.Co...
Hi there,
can anyone help?, i am stuck with a linq query..
basically i have a standard linq query that returns fields, 1 field (insurances) is actually another linq query like so
// original from this in etc not included to keep msg short>
select new Models.Custom.House.Insurance()
{
Id = v.IdH...
Hi there,
can anyone help me write a linq query, its a bit confusing... Basically i have a variable which numeberOfDays in my code which for this example is 8
I have a table that lists this.
DayFrom DayTo Price
1 3 20
4 5 30
6 8 40
8 25 150
I need to return fr...