I would like to know how I can count the number of unique values in a jagged array.
My domain object contains a string property that has space delimitered values.
class MyObject
{
string MyProperty; //e.g = "v1 v2 v3"
}
Given a list of MyObject's how can I determine the number of unique values?
The following linq code returns an...
I ran into an interesting error with the following LiNQ query using LiNQPad and when using Subsonic 3.0.x w/ActiveRecord within my project and wanted to share the error and resolution for anyone else who runs into it.
The linq statement below is meant to group entries in the tblSystemsValues collection into their appropriate system and ...
What is the reason for changing the order of these operators by Microsoft?
Microsoft don't use select-from-where and change this order to from-where-select. Why?
Is it only for better intellisense in VS?
...
Can anybody explain in detail how to implement a left outer join in LINQ?
...
In my web application, I have a dynamic query that returns huge data to datatable, and this query is often recalled with different parameters. So database is exhausted.
I want to get all record with no parameters to an object, and perform queries (may be with linq) on this object. So database will not be exthausted.
Which objects can b...
I have a simple xml doc I am reading, a sample is here:
<people>
<person>
<name>joe</name>
<age>21</age>
<contact>
<phone-nums>
<phone-num>
<number>123-4567</number>
<type>home</type>
</phone-num>
<phone-num>
<number>123-4567</number>
<type>office</type>...
I have a LINQ statement like this:
var media = (from p in postService.GetMedia(postId)
select new
{
PostId = postId,
SynthId = p.SynthId
});
There are many(possibly thousands) of records returned with the same SynthId. I want to select one one, any random one. So...
Is there anyway to use LINQ to obtain the maximum of each columns for two dimensional arrays?
Assume that I have the following:
var arrays = new double[5,100]();
I want to get the maximum of arrays[0,:], arrays[1,:] .... arrays[4,:]. How to use LINQ to do it?
I could have use such method
public double GetMax(double[,] arr, int rowI...
Hi.
We have issues within an application using a state machine. The application is implemented as a windows service and is iteration based (it "foreaches" itself through everything) and there are myriads of instances being processed by the state machine.
As I'm reading the MEAP version of Jon Skeets book "C# in Depth, 2nd ed", I'm won...
I have a list of objects, can be of any type T.
How to select a list of objects that appear in that list only once using linq? For example, if my list is
{2,3,4,5,8,2,3,5,4,2,3,4,6}, then the output should be {6,8}.
...
This is the definition:
public static IEnumerable<TResult> OfType<TResult>(this IEnumerable source);
How to replace TResult with something like:
Type.GetType("MyClass from assembly");
...
Hi,
I'm passing from the controller an array generated by the next code:
public ActionResult GetClasses(bool ajax, string kingdom)
{
int _kingdom = _taxon.getKingdom(kingdom);
var query = (from c in vwAnimalsTaxon.All()
orderby c.ClaName
select new { t...
I am using dynamic linq to make a generic class for processing a generic JqGrid from MVC all works fine (searching, pagination etc) except for sorting on code properties. Sorting works fine when I am hitting the DB to sort the data, but as soon as it is a property I have made the sorting does not work eg
public partial class tblStockO...
Customer.text is a field in an T-SQL DB (that I do not control and thus may not alter) of type "text".
I'd like to do something like this:
List<string> compare = new List<string>();
compare.Add("one");
compare.Add("two");
var q = from t in customer
where t.text.Contains( compare.First())
select t;
this will work.
Bu...
Hi,
I have a collection of image paths, and a larger collection of Image objects (Which contain a path property). I have the code to check for any matching images, but if there are supposed to be four matching image paths (as that is how many are in the first collection), and there is less than this, how can I get the missing one withou...
Is there any alternative to this:
Organizations.Include("Assets").Where(o => o.Id == id).Single()
I would like to see something like:
Organizations.Include(o => o.Assets).Where(o => o.Id == id).Single()
to avoid the hard-coded string "Assets".
...
I have a class Something that implements ISomething. How can I convert/cast from an IQueryable<Something> to an IQueryable<ISomething>. When I try to cast, I am able to compile, but the result of the cast is always NULL.
Background: The reason I am doing this is because my Something class is a CodeSmith-generated class (PLINQO templa...
I have three tables, tblCompany table, tblParts table and a link table between them tblLinkCompanyParts. Since tblLinkCompanyParts is a link table so the columns that it has are LinkCompanyPartID(primary key), CompanyID from tblCompany table and PartID from tblParts as foreign keys.
I have tied them up in the dbml file. In code if I wri...
Hi I have a really complicated dynamic query
that i want to use to retrieve data from the database
I am working in .net 3.5 sql server 2008
i created a stored procedure that accepts a varchar(max) as input parameter and does
execute (@SqlQuery)
it executes but does not return anything
I really would like to use LINQ as all my proje...
Hi all,
the question is basically in the title. Also if anyone has started some kind of implementation but never finished it and is willing to share it, I'm interested! :)
Or if it is being used internally in an open-source project...
greetings,
Tim
...