I am desperately trying to use LinqKits PredicateBuilder to allow the user to enter a search term into a text box and return records from two database tables/entitysets but I'm struggling to get anywhere. The (simplified) database structure is as follows:
Person Alias
------ ------
A_I...
Hi,
I'm trying to pre-fetch some foreign key data using a linq query. A quick example to explain my problem follows:
var results = (from c in _customers
from ct in _customerTypes
where c.TypeId == ct.TypeId
select new Customer
{
Custo...
I cant understand why resultSet2 is empty! Only the first assert passes!
List<Tree> resultSet1 = this.datacontext.Trees.Where(t=>t.RiskRating.Contains("bad")).ToList();
Assert.IsTrue(resultSet1.count() == 3);
List<Tree> resultSet2 = this.datacontext.Trees.ToList().Where(t=>t.RiskRating.Contains("bad")).ToList();
Assert.IsTrue(resul...
I have 3 sql tables SourceKeys, Channels, and ChannelTypes. These tables are queried and their data is stored in datatables in my dataset.
What I need is this:
SELECT ...
FROM ChannelTypes ct
LEFT OUTER JOIN Channels ch ON ct.channelTypeID = channelTypeID
LEFT OUTER JOIN SourceKeys sk ON ch.channelID = sk.channelID
but in linq form....
Using the System.Linq.Dynamic namespace I am able to construct a generic column list to search based on the columns present in the current usercontrol (a searchable grid we use in various places). The process is simple, take the column list visible to the current user, append the columns into a dynamic query expression in a where clause...
Here is my code
var bms = from b in context.bookmark
join q in context.question1Set on b.bookmark_id equals q.question_id
join u in context.userinfo on b.bookmark_ownerid equals u.user_userid
where b.bookmark_ownerid == new Guid(userid.ToString()) && q.question_isdeleted == ...
Following on from suggestions, I am trying to use List.GetItems(Query) to retrieve my initial data subset rather than the entire list contents via List.Items. However, whereas List.Items.Cast() results in a usable IEnumerable for Linq, List.GetItems(Query).Cast() does not.
Working Code:
IEnumerable<SPListItem> results = SPContext.Curr...
Hi all,
Fairly new to LINQ and trying to wrap my head around extension methods. What I'm attempting to do:
1) Have a table with three columns, col1 (string), col2 (double), col3 (DateTime)
table1.Rows.Add("string 1", 1, new DateTime(2009, 01, 01));
table1.Rows.Add("string 1", 2, new DateTime(2009, 02, 01));
tab...
Is there a way to refactor linq to sql and take advantage of late evaluation? Is there a way to reuse object initilizer code?
I have business objects that are persisted in a database and hydrated via a separate linq to sql layer.
I would like to be able to reuse code from multiple queries that do the exact same thing. The portion of t...
Hi All
Is there a way to Take a given XML file and convert (preferably using C# Generics) it into a Concrete Ienumerable list of T where T is my concrete class
So for example I may have an XML file like
<fruits>
<fruit>
<id>1</id>
<name>apple</name>
</fruit>
<fruit>
<id>2</id>
<name>orange</name>
<...
Hi,
I want to write a linq expression that will return the ID that does not contain a particular value. For example, I want to return all distinct IDs that do not have Value = 30.
ID, Value
1, 10
1, 20
1, 30
2, 10
2, 20
3, 10
3, 20
The result should be 2 and 3 since non of these have a Value with 30.
Is this possible t...
Say I have:
IList<Person> people = new List<Person>();
And the person object has properties like FirstName, LastName, and Gender.
How can I convert this to a list of properties of the Person object. For example, to a list of first names.
IList<string> firstNames = ???
...
I want to find out what query string was sent to sql server from using Linq to Entities.
...
How can I create a dictionary with no duplicate values from a dictionary that may have duplicate values?
IDictionary<string, string> myDict = new Dictionary<string, string>();
myDict.Add("1", "blue");
myDict.Add("2", "blue");
myDict.Add("3", "red");
myDict.Add("4", "green");
uniqueValueDict = myDict.???
Edit:
-I don't care which k...
Is it possible to create a LINQ compiled query that utilizes an ITVF (inline table valued function)?
...
I've been working on a silverlight application which generates various graphs. It requires a bit of number crunching as well as getting a decent amount of data from the database.
For my db communications I created a web service which uses Linq2SQL. To overcome the issue of my web service blowing up, I chunk up the data which results in...
This might seem to be a silly question at first, but please read on.
I know that LINQ queries are deferred and only executed when the query is enumerated, but I'm having trouble figuring out exactly when that happens. Certainly in a For Each loop, the query would be enumerated. What's the rule of thumb to follow? I don't want to acci...
I have a variable of type Dictionary<MyType, List<MyOtherType>>
I want to convert it to a Lookup<MyType, MyOtehrType>.
I wanted to use Lambda functions to first, flatten the dictionary and then convert this to Lookup using the ToLookup(). I got stuck with the dictionary. I thought about using SelectMany but can't get it working. Anyon...
I am on my way of linq learning and would like to see how linq is applied in the real world projects. So is there anyone who can suggest some open source C# and VB projects that employs Linq technology within?
...
I'm hoping there's a simple answer to this one I've missed in hours of Googling...
I have a DataGridView which needs to display and add/delete/edit records from a database. I'm using the Entity Framework, so records are initially EntitySet.
Attempt One
BindingSource has facilities for sorting, but oh... they don't seem to actually ...