I have two lists A and B (List). How to determine if they are equal in the cheapest way? I can write something like '(A minus B) union (B minus A) = empty set' or join them together and count amount of elements, but it is rather expensive. Is there workaround?
...
I've found some articles about using the RandomView view and the GetNewID function to pull back randomized records, but they are using this method with Linq to SQL which allows Functions and Stored Procs to be used with no return value or a scalar return value. From what I understand, a Stored Proc has to been returned as one of the Enti...
I'll preface this with saying I'm day 8 into life as a C# developer.
For a number of DomainModels in the project I am working on, I need the ability to filter all records in a table given what a user submits in a review/search form.
Currently the 2 cent short tour is:
Form submits to FooController/review.
Review then grabs all key/va...
I've been working with the xml.linq classes in .net recently. But may need to use a linux friendly language for an upcoming project.
The things I like the most are
Xdocument, being able to load from a
file or parse from a string
XElement, quickly creating a custom
structure for page specific data
Traversing Children, Parents,
Sib...
Hi
I am working on a mobile.net project.
I am trying to make a list of restaurants which is displayed in a drop down list...whn d user selects an item he can add it to d list of favorites.
However i am getting an error
Description: An error occurred during the compilation of a resource required to service this request. Please review th...
I'm playing with Linq-SQL and would like to display my data in a TreeView on a form. I'm also using .net 3.5, if that matters.
Now, my question - is there a better way to populate this treeview? The way I'm doing it now is like this (psuedo):
for each order
{
OrderNode = new TreeViewNode
for each product in order
{
Produ...
Hi,
I am working on an ASP.NET application using LinqToSQL. When the page loads I run a query and save the results into a variable... var tasks = query expression. I then save this into a session variable Session["Tasks"] = tasks...
Is it possible to cast this session object back to its original var state, so I can run methods such as...
I have a data setup of the following form: State 1->n County 1->n City.
Within my State object, I want to return all counties that contain at least one city with a population greater than p. Were I to write this in sql it would be:
select distinct co.*
from County co join City ci on ci.CountyID = co.ID
where ci.Population > @p
and co....
Hello,
I want to edit a gridview on an other page when the user click on the edit button. If possible in a detailview. There is not example to how do it with linq. Do you know a good tutorial ?
Thank you.
...
Hi,
I'm not really familiar with LINQ, but I'm currently working on an ASP.NET project and using LINQ to SQL as ORM (I'm building a route planning application). I have a problem creating a query the way I need it, so maybe anyone could give me a hint how to achieve this. My current query looks like this:
var results = from lift in db.L...
The following code works but only as long as each element of the XML has an "Id" attribute.
However, if an element does not have an id attribute, LINQ throws an NullReferenceException.
How do I specify that if there is no Id attribute, just assign a null or blank?
using System;
using System.Linq;
using System.Xml.Linq;
namespace Tes...
If you have custom type, and you wish to assign a List(of T) to that custom type, how do you do so in vb? I found a C# example as below
List<myclass> result = (from c in db.Customers where c.orders.count > 1 Select new Myclass
{
Id = c.customerID,
Name = c.contactname
}).Tolist();
From this site http://blogs.msdn.com/swiss_dpe_team/a...
With LINQ I get four elements out of some XML, each element can have a different name (Book, Magazine, Article).
How do I get the name of the element I'm currently processing, e.g. something like ElementType() below:
using System;
using System.Linq;
using System.Xml.Linq;
namespace TestXmlElement2834
{
class Program
{
...
I need to filter a strongly typed list of type StaffingPositionsDataContract, with another list of filter names and values. I have these two lists:
List<SerializedForm> deserializedObject = JsonConvert.DeserializeObject<List<SerializedForm>>(searchFilters).Where(x => !string.IsNullOrEmpty(x.value) && !string.Equals(x.value.ToUpper...
When I have a table in database with many rows
and I want to display them by normal line (Not with Gridview). Like:
You teach these classes:
class 1/1, class 2/1, class 3/1
we take (1/1 and 2/1 and 3/1) from database.
how can I do it ?
note: I use LINQ to deal with database.
...
We've been doing a lot of work with LINQ lately, mainly in a LINQ-to-Objects sense. Unfortunately, some of our queries can be a little complicated, especially when they start to involve multiple sequences in combinations. It can be hard to tell exactly what's going on, when you get queries that start to look like:
IEnumerable<LongType...
How do I alter the contents of an IDictionary using C# 3.0 (Linq, Linq extensions) ?
var enumerable = new int [] { 1, 2};
var dictionary = enumerable.ToDictionary(a=>a,a=>0);
//some code
//now I want to change all values to 1 without recreating the dictionary
//how it is done?
...
I'm in the process of speeding up Linq to SQL queries in a web app by converting them to Compiled queries and I ran into a problem converting a very simple statement.
I want to compile a simple statement that uses the following parameters to get valid employees from the database:
TestParams myParams = new TestParams
{
ValidEmps = n...
This is a question about LINQ the .NET language feature, not LINQ to SQL.
I find that the ability to query almost any in memory collection in such a consistent and declarative way is one of the best language features I've ever come across.
I find it extremely useful, and I love the clean abstraction it provides. LINQ can even be used t...
Hi,
I want to add some rows to a database using Linq to SQL, but I want to make a "custom check" before adding the rows to know if I must add, replace or ignore the incomming rows.
I'd like to keep the trafic between the client and the DB server as low as possible and minimize the number of queries.
To do this, I want to fetch as little...