Say I have one database, and this database has a set of tables that are general to all Clients and some tables that are specific to certain clients.
Now what I have in mind is creating a primary DataContext that includes only the tables that are general to all the clients, and then create separate DataContexts that contain only the tabl...
Is the Linq Count() method any faster or slower than List<>.Count or Array.Length?
...
I am filtering the list of entries from my DataContext with a Linq-statement. After that I assign them to the the ItemsSource-property of the DataGrid available in the WPFToolkit. The available entries are being shown, but for some reason I am not able to insert a new row into the Datagrid.
Surprisingly it all works fine if do not use t...
public string GetNameBySSN(string SSN)
{
var results = from c in Clients
where c.ClientSSN.Equals(IRRCNumber)
select c.FirstName;
//return results.ToString();
}
I want to return a single column value with Linq and not sure if there is way to do a quick easy return. I commented section of c...
I have a collection of Items that each have a collection of Relationships. I have a list of Groups that Items can have Relationships with.
I can find all the Items that have a particular relationship but I now want to find all the Items that don't have a Relationship with any of my Groups.
I can find the Items that have a relationship...
Here's the problem. The code below works fine on my development PC, but when I deployed the app, it crashes.
Here is the lines of code that are relvant
Private TdsTypesList As List(Of TDS_Type)
...
TdsTypesList = (From tt In db.TDS_Types Select tt).ToList
This is the error I get
Exception Source: Anonymously Hosted DynamicMeth...
Hi
I have a Posts class and that post can have one file and that file can have many tags
I want to iterate through the files in a post and show all the files tags
foreach(File f in Post.Files)
{
f.Tags
}
What do I need in this foreach to get the top tag? there will only ever be one.
i tried
f.Tags.Select(n => n)
with no luc...
I have a linq query that returs a list of int. I want to count all the items in the list. then count all the items with number 0 and then remove items with 0 from the list.
please show simple example,mine is a ugly.
...
Hi,
i have a list of articles, and each article has one or more votes in a collection.
It's a entity framework collection, but i don't think that makes a lot of difference for the problem.
Navigating goes like this:
Article.Votes, where Votes is a collection of vote objects.
What i'm looking for is the Linq statement how i can find the...
I am generating Linq classes by running SQLMetal from the command line against a Compact 3.5 database. The Compact 3.5 database is a local database cache (generated by the Sync Framework "Create Local Database Cache wizard).
CE seems to support foreign keys constraints, but I am not seeing any, and SQLMetal does not generate them into th...
I have a generic
List<MyClass>
where MyClass has a property "InvoiceNumber" which contains values like:
200906/1
200906/2
..
200906/10
200906/11
200906/12
My list is bound to a
BindingList<T>
which supports sorting with linq:
protected override void ApplySortCore(
PropertyDescriptor property, ListSortDirection directi...
Hi
i am facing some problems in my project. when i try to update entity it gives me different type of errors.
i read from net. these errors are because
1 - I am getting Object of entity class from method which creates DataContext locally
and in update method id does not update because here another DataContext is created locally.
(eve...
Code:
public IList<T> GetByMultipleIds(int[] ids)
{
List<T> result =
_session.Linq<T>()
.Where(x => ids.Contains(x.Id)).ToList();
return result;
}
Throws:
An exception of type 'System.NullReferenceException' occurred in
NHibernate.DLL but was not handled in user code
Additional inform...
I like to reuse expressions for DRY reasons, but how do I reuse the expressions within a LINQ statement?
e.g.
I have
public static class MyExpressions {
public static Expression<Func<Product,bool>> IsAGoodProduct() {
return (p) => p.Quality>3;
}
}
And would like to use that in LINQ statements, so
var goodProds = ...
Hi all,
Here is the scene.
Agents -> Organization -> Schools
Agents -> Persons -> Educators
So each of the 5 tables exist in the data base. The AgentId (GUID -> uniqueidentifier) is generated in the Agents table and I need it to be passed on to Organization -> Schools or Persons -> Educators.
But Linq to SQL does not reconize that, an...
I just upgraded my project to .NET 3.5 and thought I had a perfect use for LINQ. My application has a window manager that tracks open windows at runtime and I'm trying to add a FindOpenWindows generic method. What I've done so far:
List<Form> openWindows;
public List<T> FindOpenWindows<T>(Predicate<T> constraint)
{
...
I think I'm missing something really basic.
var signatures=from person in db.People
where person.Active==true
select new{person.ID, person.Lname, person.Fname};
This linq query works, but I have no idea how to return the results as a public method of a class.
Examples always seem to show returning the ...
I have a table with a list of countries in it that I'm using to populate a dropdown.
How can I construct a LINQ query so it will return the list of countries from that table in alphabetical order, with the exception of placing USA at the top?
So, if the table contained:
Sweden
USA
Mexico
Denmark
It would return:
USA
Denmark
Mexico
S...
I wrote this example to help explain. As you can see I have an object hierarchy. I'd like to modify the GetFeatures() function to only return the features added by constructor of object type I instantiated. For example, BasicModel.GetFeatures(new LuxuryModel()) should only return the features "Leather Seats" and "Sunroof". I don't mind u...
I'm about to start my first LINQ (to Entities) 'enabled' project, and it immediately strikes me how easy it is to draft SQL queries in SQL Server vs. writing and running code to check results. What do people usually do here? Prototype in T-SQL then implement in code, or use a tool, or what?
...