Hi,
I'm getting "InvalidCastException" (occurred in System.Data.Linq.dll) in my function:
public User GetUserByKey(Guid key)
{
return usersTable.FirstOrDefault(m => m.UserKey == key);
}
which is called here:
MembershipUser mu = Membership.CreateUser(user.UserName, user.Password, user.Email, null, null, true, Guid.NewGuid...
I am trying to write a LINQ statement which selects only the rows in a table with the most recent rundate. For example, if I had a table with columns RunDate(datetime) and Value(decimal) one way of accomplishing this through sql might look like:
SELECT Value
FROM Table
WHERE RunDate = (SELECT MAX(RunDate) FROM Table)
Is there a way t...
I know how to call the Union extension method, e.g.
Dim r = productFirstChars.Union(customerFirstChars)
However I do I do this with the Linq syntax, e.g.
from productFirstChars select ????
...
Hi!
I deal with a framework on a daily basis where we sometimes provide methods that accept IEnumerable<MyBusinessObject> as a parameter in order to show user interfaces, perform calculations etc.
If I pass in an array of MyBusinessObject like so:
MyBusinessObject[] myArray = new MyBusinessObject { obj1, obj2, ..., objN };
frameworkCl...
Hello,
I have 2 objects that contains generic list properties.
IE :
public class User
{
public string Sid { get; set; }
public List<Group> Groups { get; set; }
}
public class Section
{
public string Sid { get; set; }
public List<Group> Groups { get; set; }
}
From my BLL I get a generic list of sections
List mySection...
I am using Fluent NHibernate and would like to use linq to query my database is this possible ?
...
Hi,
Is it possible to improve the efficiency of those linq requests? I use two different loops...
Can you help me to optimize this code?
double[] x = { 2, 3, 1, 5, 7, 2, 3 };
double[] y = { 1, 2, 3, 4, 5, 6, 7 };
IEnumerable<int> range = Enumerable.Range(0, x.Length);
double[] y_sorted = (fro...
Is there a LINQ way to swap the position of two items inside a list<T>?
...
How do you promote and/or sell LINQ syntax to colleague that doesn't see the benefit over the manual way of doing thing?
For an example using Linq to Entity/Sql instead of using plain ado.net without any LINQ.
...
Hi, using Telerik RadGrid* in a LINQ context, with ASP.NET/C#, how to truncate text to a maximum length when displaying in columns? By maximum, I mean if original string's length is shorter than the specified maximum length, no errors will raise.
I have seen many examples of this on the net, but it seems that the Container.DataItem use...
Hello.
This is the code:
IEnumerable<table> results = db_dane.ExecuteQuery<table>(query);
table - is a database table,
query - sql query (example: select * from table),
db_dane - linq datacontext.
How to convert results of this query to xml or dataset?
...
Below is my calsses. I have a product that contains list of days. Each day has a city property.
I need to create a linq query that will give me the distinct cities that are used on all my products in the system.
I tried something like this but does not work;
var cities = from product in NHibernateSession.Linq<Product>() select new { c...
While trying a sem-complex query to display some ListView content on the page I got stuck on the famous "Only parameterless contstructor and initializers are supported in LINQ to Entities" error.
Here is the code I used ... I can't find a place where I initialized something inside the query with parameters ....
protected void ArtistsL...
I came across a rather strange problem with linq-to-sql. In the following example,
var survey = (from s in dbContext.crmc_Surveys
where (s.crmc_Retail_Trade_Id == tradeId) && (s.State_.Equals(state))
select s).First();
If tradeId is null, it doesn't behave as if I h...
I know that it might not be the most performant, but I want to process some logs with a LINQ statement. Here is what the log looks like:
RECORD DEVON 1 6748
bla bla bla bla bla bla
bla bla bla bla bla bla
RECORD JASON 1 7436
bla bla bla bla bla bla
bla bla bla bla bla bla
RECORD DEVON 2 9123
RECORD DEVON 3 3723
RE...
Is there a better way to do this?
public bool IsServiceRunning(string serviceName)
{
string[] services = client.AllServices();
return (from s in services
where s.Equals(serviceName, StringComparison.InvariantCultureIgnoreCase)
select s).Count() > 0;
}
The case insensitivity ...
How is something like this done in linq? It has filter criteria on the JOIN.
This is taken from this question: http://stackoverflow.com/questions/1401889/sql-filter-criteria-in-join-criteria-or-where-clause-which-is-more-efficient
select salesman.salesmanid, max(sales.quantity)
from salesman
inner join sales on salesman.salesmanid =sa...
So my situation is that I have a linq-to-sql model that does not allow dates to be null in one of my tables. This is intended, because the database does not allow nulls in that field. My problem, is that when I try to write a Linq query with this model, I cannot do a left join with that table anymore because the date is not a 'nullable...
Hello,
I'm having a problem with a linq query. I have used this similarly before but i cannot understand what could be wrong now.
Errors
The best overloaded method match for
'System.Collections.Generic.List.Contains(int)'
has some invalid arguments
Argument '1': cannot convert from 'int?' to 'int' ; refers to the where clause ...
Hello,
I have been working with a Linq query in a Silverlight application which returns only the row of a table which contains the max value of the field OptionARMRunId (identity). When executed in LinqPad, the query runs fine and returns the correct row. However, when used in my Silverlight application, the application never moves pas...