Hi,
I was attempting to dynamically create a Where predicate for a LINQ2SQL query:
...Where(SqlMethods.Like(r.Name, "%A%") ||
SqlMethods.Like(r.Name, "%B%") ||
SqlMethods.Like(r.Name, "%C%") || ...)
A, B, C, etc. come from some array. So I tried the following:
var roleExpression = Expression.Parameter(typeof(Role),...
I just looked at one of those libraries that is of the naming schema "something-Linq" expecting to gain some more knowledge on how to construct expression trees in an elegant way - and was disappointed. Because all I could find were methods that extended IEnumerable - of course with "normal" C# code.
Now I have this question: Do non-exp...
I am beginning to use LINQ in general (so far toXML and toSQL). I've seen that sometimes there are two or more ways to achieve the same results. Take this simple example, as far as I understand both return exactly the same thing:
SomeDataContext dc = new SomeDataContext();
var queue = from q in dc.SomeTable
where q.SomeDate <= ...
Hi All,
Following on from this question:
Linq-to-SQL ToDictionary()
I have a table called Domains, it has two columns:
DomainID int
DomainName varchar(250)
I want to return a Dictionary<int, string>. When I try either of the following LINQ to SQL code:
Dictionary<int, string> dict =
dbc
.Domains
.Select(d => new {d.Dom...
Is there a built in linq method thing I can use to find out if two sequences contains the same items, not taking the order into account?
For example:
{1, 2, 3} == {2, 1, 3}
{1, 2, 3} != {2, 1, 3, 4}
{1, 2, 3} != {1, 2, 4}
You have the SequenceEquals, but then I would have to Order both sequences first, wouldn't I?
...
Hi.
I have two tables. One table contains comments on posts, another contains commenter information like nickname, site, etc..
There is FK relations betwin two tables
Comment.CommenterId -> Commenter.Id
Whenever user posts a comment I need to add comment and commenter at the same time.
The problem is that I don't know what would be Comme...
Hi,
I have this fragment of code:
SmsDataClassesDataContext dc = new SmsDataClassesDataContext();
// Get the customer
Customer currentCustomer = dc.Customers.Single( c => c.Hash1 == forThisHash );
// Get from Name (LINQ to XML)
var q = from c in thisSmsPack.Descendants("from")
select...
Ok im trying to get a MVC example page working and basically query where a certain id is specified but i'm fairly new to it all and after an hour of trying to figure this out im hoping of you can help me!!
code below is a method from my taskController.cs that is called via /tasks/complete/2
//mark task as complete
public ActionRes...
Hi all. Linq noob here. I read about Linq but I don't quite understand in what circumstance to use Linq. Does anyone have an example?
thank
Jack
...
Hi all
I have an asp.net application developed. It uses LINQ to SQL to access database, using the .dbml designer in Visual Studio 2008. We are installing the application on client, and they have decided to change the database name on their servers. Now, the application does not work because LINQ can't find the database information. This...
I am trying to get this LINQ query to return exact matches if they exist or the "startswith" result if not. Right now it returns both.
example
SearchParam = "mundt"
Results = Mundt, Mark | Mundt, Chris | Mundth, Lori
public static DataTable SearchPerson(string SearhParam)
{
var context = new ConnectDataContext(Properties....
I have the following c# linq query:
var duplicatedSSN =
from p in persons
group p by p.SSN into g
where g.Count() > 1
select g.Key;
Can anyone help me convert this to a vb.net linq query?
Many Thanks!
...
I am working with a LINQ to SQL query and have run into an issue where I have 4 optional fields to filter the data result on. By optional, I mean has the choice to enter a value or not. Specifically, a few text boxes that could have a value or have an empty string and a few drop down lists that could have had a value selected or maybe ...
List<MyParentClass> parents = new List<MyParentClass>();
var parent1 = new MyParentClass("parent1");
var parent2 = new MyParentClass("parent2");
parents.Add(parent1);
parents.Add(parent2);
var child1 = new MyChildClass("child1");
parent1.children.Add(child1);
var child2 = new MyChildClass("child2");
va...
I want to write a Linq to Sql query that does a count and groups by a Username and DateTime. I want the DateTime to be formatted like following "YYYY-MMM" (i.e. 2009-Mar).
I thought this would work but Linq to Sql can't parse the ToString "format" argument.
dc.MyTable
.GroupBy(r => new
{
...
I am trying to understand LINQ and become confident at using it. What I am struggling with are the parameters asked for. Example:
var sortedWords = words.OrderBy(a=>a.Length)
words is an array collection. OrderBy's intellisense says:
Func<string, TKey> keyselector
A func executes a method, and a string is the value, TKey a key.
In...
Caan somone advise the best approach to what i'm trying to acheive (linq to sql, returning list of data to show in a grid/list etc etc)... Its complaining about anonymous type conversion, and from what i'm reading, thats not elegant way of doing it.
Public Function GetHistory(ByVal historyId As Integer) As List(Of ?????????)
Using...
How can you make something like this generic
return from items in _db.Table
select items;
I would like to do something like this
public class Data<T> ( where T is the model object )
so the Table will change to the value of T
How would this look as a generic class with a save method for instance
Thanks
...
Is possible to use the Signum Framework with previous versions of .NET, 2.0 specifically?
...
How do I order by child objects in LINQ?
Classes A, B, and C. A has a collection of B and B has a collection of C. I want to order object A by the Ordinal (int) property of C.
var query = from a in db.A
orderby a.Bs.OrderBy(x=> x.C.Ordinal) <--- ??
select a;
I can't seem to figure out the orderby statement for thi...