Here is my query:
m_SelectedHandler = m_ListOfHandlers.SingleOrDefault(h => h.CountryNames.Contains(country.ToLower());
country is a string and an argument to the method containing the assignment above. CountryNames is a list of strings. How can I call ToLower on each of the strings in CountryNames so that I'll get valid matches for...
I have a following tables/classes structure in Linq to entities.
Books
{
bookId,
Title
}
Tags
{
TagId
Tag
}
BooksTags
{
BookId
TagId
}
Now I need to write a query which gives me result like this
Class Result
{
bookId,
Title,
Tags
}
Tags should be comma separated text from the tags table by joining all three tables.
How...
So I've just started working with linq as well as using lambda expressions. I've run into a small hiccup while trying to get some data that I want. This method should return a list of all projects that are open or in progress from Jira
Here's the code
public static List<string> getOpenIssuesListByProject(string _projectName)
{...
I have a query that sums and aggregates alot of data something like this:
var anonType = from x in collection
let Cars = collection.Where(c=>c.Code == "Cars")
let Trucks = collection.Where(c=>c.Code == "Trucks")
select new {
Total = collection.Sum(v=>v.Amount),
...
var setsA = new List<SetA> {
new SetA { SsnA = "3450734507", name = "setA"},
new SetA { SsnA = "6833467788", name = "setA"},
new SetA { SsnA = "5452347787", name = "setA"},
new SetA { SsnA = "9345345345", name = "setA"},
};
var setsB = new List<SetB> {
new SetB { SsnB = "5452347787" ,n...
Consider the need to search a list of Customer by both first and last names. The desire is to have the results list sorted by the Customer with the most matches in the search terms.
FirstName LastName
---------- ---------
Foo Laurie
Bar Jackson
Jackson Bro
Laurie Foo
Jackson Laurie
...
I was wondering if there is easy solution to this or I'm stuck with following:
When updating DB:
dti.Pass = Crypter.Encrypt(dti.Pass);
_db.SubmitChanges();
When selecting from DB:
Data.DbTableItem dti = _db.Single(a=>a.Id == id);
dti.Pass = Crypter.Decrypt(dti.Pass);
Meaning - I am not really into writing repetitive code and thi...
I am trying to figure out how to dynamically specify the properties for my select clause in a linq query.
Lets say I have a collection of employee objects. At run time, the end user will be specifying which properties they would like to see for those employees, so I need to be able to dynamically construct my Linq select clause.
I h...
I have two ways that I am doing a fuzzy search for a customer. One is by an abbreviated name and the other is by the customer's full name. When I take these two result sets and then union them together (which I have read several places should remove distinct values) I get duplicates. Thinking that all I need to do is then call the .Disti...
Suppose I have a list or array of items, and I want to sum a subset of the items in the list. (in my case, it happens to always be a sequential subset).
Here's the old-fashioned way:
int sum = 0;
for(int i = startIndex; i <= stopIndex; i++)
sum += myList[i].TheValue;
return sum;
What's the best way to linqify that code?
...
add-type -Language CSharpVersion3 -TypeDefinition @"
public class pack_code
{
public pack_code() {}
public string code { get; set; }
public string type { get; set; }
}
"@
$a = New-Object pack_code
$a.code = "3"
$a.type = "5"
$b = New-Object pack_code
$b.code = "2"
$b.type = "5"
$c = New-Object pack_c...
var itemSet = from item in da.GetList<Models.account>()
join file in objFileStorageList
on item.account_id equals file.parent_id into objFile
from fileItem in objFile.DefaultIfEmpty()
where item.company != null && item.company.comp...
My friends were having discussion on nested lists of objects in LINQ and when I asked what does that mean, they laughed :(
Can anyone here tell what is nested list. is it same like list inside list? Thank you to all who help me
Is this NestedList?
public class X
{
public Y[] y { get; set; }
}
public class Y
{
int id { get; set; }...
When I have a string like "0xd8 0xff 0xe0" I do
Text.Split(' ').Select(part => byte.Parse(part, System.Globalization.NumberStyles.HexNumber)).ToArray();
But if I got string like "0xd8ffe0" I don't know what to do ?
also I'm able for recommendations how to write byte array as one string.
...
I have written the below
return (from p in returnObject.Portfolios.ToList()
from childData in p.ChildData.ToList()
from retuns in p.Returns.ToList()
select new Dictionary<DateTime, double> ()
{ p.EndDate, retuns.Value }
).ToDictionary<DateTime,double>();
Getting error
No overload for method 'Add' ...
How can we get an autogenerated Id from the Table While Inserting?
I have three tables
Project
ProjectXMilestone
Milestone
and on Insert of Milestone I also want to insert a row in 2nd Table so I need MilestoneId?so how can I get that?
I am using Linq.
...
I am using the following class
class Country
{
int CtryID {get; set;}
List<City> city {get; set;}
}
class City
{
string county {get; set;}
int sqkm {get; set;}
}
The CtryID has values like 1,2,3 and county has values like "County 1" , "County 2" and so on
I want a result like this
1
County 1
County 6
County...
Hi,
I write Linq query for keep on fetching data from database. First loop table don't
have record , so throwing exception. After first loop i have record in the database, my
query is working properly. Below i specified my query give some suggestion first
loop(no records in table) i have to modify query or query have to change.
Ex:
...
I´m (professionally) creating a SQL Server database client by using Visual Studio 2008, C# -> Windows Form(s). And I´m using all the built in stuff, provided by my friend VS Studio, dragging and dropping, creating SQL query tables in DataSet.xsd, and so on... I like that.
But!
I would like to try out LINQ, as I would like to have somet...
I am using the following class
class Country
{
string CtryID {get; set;}
List<City> city {get; set;}
}
class City
{
string county {get; set;}
int sqkm {get; set;}
}
I want to order the result like this
Here's is some sample data for Country and City
Country
US
UK
Canada
City
CityC
CityF
CityA
CityB
CityG
CityD
...