I have a class with two properties, say
public class Book {
public string TitleSource { get; set; }
public string TitleTarget { get; set; }
}
I have an IList<Book> where the TitleTarget is null and for each item in the list, I need to copy the TitleSource property to the TitleTarget property. I could do this through a loop, sure, but ...
I want to make the following query dynamic.
var t = from r in dt.AsEnumerable()
orderby r.Field< int >("id") ascending
select r;
void query(string sorttype,string sortorder)
Is it possbile to change the order by part so that those paramater will come from parameters of a function like
sorttype for id in here and sortorder for ascen...
Can I improve this LINQ query
var filter = from Dep in deptlist
where (Dep.DepNm.StartsWith(txt1.Text.ToLower())
|| Dep.DepNm.StartsWith(txt1.Text.ToUpper())
||Dep.DepNm.Contains(txt1.Text))
select Dep;
...
Hi
i asked this a few weeks ago, but couldnt get any of the suggested answers working, so i would be grateful for any help on this:
i have a list of event Ids returned from an xml document as shown below
public IEnumerable<EventFeed> GetEventIdsByEventDate(DateTime eventDate)
{
return (from feed in xmlDoc.Descendants("Show")
...
Is there a way with subsonic to preform a self join?
...
I'm building a LINQ expression tree but it won't compile because allegedly the local variable $var1 is out of scope:
variable '' of type 'System.Object' referenced from scope '', but it is not defined
This is the expression tree:
.Block() {
$var1;
.If ($n.Property1 == null) {
.Block() {
$var1 = null;
...
I'm looking for rules of thumb for calling ToList/ToArray/MemoizeAll(Rx) on IEnumerables, as opposed to returning the query itself when returning IEnumerable of something.
Often I find that it is better to just return the query and let the caller decide whether a list is needed or not, but sometimes it can come back and bite you in the...
I am trying to set XElements with an ArrayList and having a bit of trouble. I basically want to be able to do a foreach loop, but not sure where I need to insert it.
ArrayList cities = new ArrayList();
foreach (ListItem item in lstCities.Items)
{
cities.Add(item.Text);
}
new XElement("Cities", cities //not sure what to do here
...
Is there a compact, built-in way to generate a range of floats from min to max with a given step?
E.g.: range(10, 20, 0.1) [but built-in].
...
I have a LINQ question. I am not great with linq. I have two classes:
[Person]
string FirstName {get;set;}
string LastName {get;set;}
IEnumerable<State> LastName {get;set;}
[State]
int StateID {get;set;}
string StateName {get;set;}
I would like to write a LINQ query that would return a distinct list of states for all "Person" classes...
hi all.
I have Three Tables in SqlServer (equivalent to image in link below in SQL Server)
http://www.mojoimage.com/free-image-hosting-view-06.php?id=2Untitled-2.gif
and when i use LINQ to Sql i get three classes in dbml file:
class Item
{
Guid ItemId;
int ItemSize;
}
class Video
{
Guid RecordId;
Guid ItemId;
string Resolution;
}
cl...
Hi all, I have 3 columns/fields as part of a generic list: strID, seq, unit
there are a bunch of strIDs that belong to the same unit and they each have a different seq. I'm interested in the row that has the minimum seq per unit(the leader of the group). How would I accomplish this with a LINQ query (a tsql query would also be fine)...
Sorry if I didn't explained it right in the title, but here it goes:
I want to do execute a LINQ query, and I have the name of the table to query stored in a variable:
string tableName = "SomeTable";
DataContext db = new DataContext();
var vResult = from t in db.tableName
where t.Id = ....
...
If I have something like this:
x = from f in first.Include("second")
where f.id == 1
select f
y = from s in second
where s.first.id == 1
select s
Will two queries be sent to my database? I realize that I could just set y = f.second to ensure that only one call is made, but I frequently want to factor my code such that...
HI, I am working on a simple class to combine items of any type... this is for a poker game, this is how it looks:
public static List<List<T>> combinar<T>(List<T> items, int take)
{
List<List<T>> combs = new List<List<T>>();
var stuff = permutar<T>(items, take);
var all = from s in stuff
select new Tuple<Lis...
There's two options for dealing with LINQ to Collections that are populated with SQL (I'm using an Oracle provider, so no LINQ without an ORM).
1) Do one big SQL query, dump the results into some sort of collection and do LINQ queries on the collection, so you have one big draw on the database, but not much slowdown after that.
2) Do s...
I'm working with a XML file that looks something like this:
<lfm status="ok">
<user>
<name>JohnnyWestlake</name>
<image size="large">http://someurl.com/large.jpg</image>
<image size="extralarge">ttp://someurl.com/exlarge.jpg</image>
...
</user>
</lfm>
And I'm adding this to a user class using ...
Strong typing is fine and dandy when you know what your schema is going to look like at compile time. But what if you're working on an application that lets the user define their own schema?
Is there a reliable relational LINQ provider out there that operates at the same level of abstraction as LINQ to XML?
Example:
var whoIsJohnGalt ...
Say I have a collection of object arrays of equal dimension, like this:
var rows = new List<object[]>
{
new object[] {1, "test1", "foo", 1},
new object[] {1, "test1", "foo", 2},
new object[] {2, "test1", "foo", 3},
new object[] {2, "test2", "foo", 4},
};
And I want to group by one or more of the "columns" -- which ones...
Hi,
Learning a bit about Linq.
I have the following code:
(Please excuse the pathetic size of the data set)
class Program
{
static void Main(string[] args)
{
var employees = new List<Employee>
{
new Employee
{
...