When I was looking to the System.Linq.Expression capabilities (creating expression trees in code, compiling them, executing them) I was asking myself if this is possible for class creation as well - specifically generic classes.
I would expect something like Expression.Class() or Expression.GenericClass(). Looking at the methods I did n...
I love new Rail 3!
The new query syntax is so awesome:
users = User.where(:name => 'Bob', :last_name => 'Brown')
But when we need to do something like
SELECT * FROM Users WHERE Age >= const AND Money > const2
We have to use
users = User.where('Age >= ? and money > ?', const, const2)
Which is not very cool. The following query...
I would like to know what is better to use.
IComparer class and Compare method for sort or LINQ orderby on List. Both works fine but which one is better for large lists.
...
<div>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
ClientInstanceName="ASPxGridView1" DataSourceID="LinqServerModeDataSource1"
KeyFieldName="ProductID"
oncelleditorinitialize="ASPxGridView1_CellEditorInitialize"
onrowdeleting="ASPxGridView1_RowDeleting"
o...
I have two double[] X and double[] Y.
I want to create a new array Z, where each Zi = Xi * Yi
I wonder if it's possible to do with LINQ?
(I'm learning LINQ now; of course I can use plain for).
...
I need to return an IEnumerable of a dynamically created Dictionary.
pseudo code:
var x = from u in Users
select new dictionary<string, string>{
Add("Name",u.Name),
Add("LastName",u.LastName)
}
I've been trying many ways to get the pseudo code example above but no success...
I would really appreciate your help.
...
I have code below that builds a collection and returns it sorted by a property
var appChanges = GetHistory().ToList();
return appChanges.OrderByDescending(r => r.Change.When);
i want this to only return a max of 50 items (or total if collection size is less than 50)
how can i do this in LINQ ?
...
Given the following query:
var query = from item in context.Users // Users if of type TblUser
select new User() // User is the domain class model
{
ID = item.Username,
Username = item.Username
};
How can I re-use the select part of the statement in other quer...
I have the following code:
[code]
<h2>Listado General de Carreras</h2>
<% foreach (var item in Model)
{ %>
<p><span class="titulo"><%=Html.ActionLink(item.Nombre, "Details" , new { id = item.ID }) %></span> <sub> Area: <%: item.Area.Nombre%></sub></p>
<% } %>
<p>
<%: Html.ActionLink("Crear Nueva Carrera", "Create") %...
Imagine I have 20 People objects.
IQueryable<Person> People;
How could I return a List of all the Peoples names using a linq query?
...
I have two dictionaries like
Dictionary<String,List<String>> DictOne=new Dictionary<String,List<String>>()
Dictionary<String,List<String>> DictTwo=new Dictionary<String,List<String>>()
DictOne
KeyOne "A"
"B"
KeyTwo "C"
"D"
KeyThree "X"
"Y"
DictTwo
Key1 "X"
"Z"
...
Bellow is my SQL syntax
CREATE TABLE [dbo].[Security_Module_Info](
[Client_Company_ID] [smallint] NOT NULL,
[Module_ID] [tinyint] NOT NULL,
[Module_Name] [nvarchar](50) NULL,
[Module_Description] [nvarchar](200) NULL,
[Is_Active] [bit] NULL,
[Active_Date] [smalldatetime] NULL,
[Record_Status] [tinyNULL,
[...
If I have a DataTable with a small or large amount of data, to select data from the datatable I can use the Datatable.Select() method or go for LINQ. Which one is faster and efficient?
...
I am writing a Linq query just for learning.
var result = Process.GetProcesses()
.Where(p => p.WorkingSet64 > 20 * 1024 * 1024)
.OrderByDescending(p => p.WorkingSet64)
.Select(p => new {p.Id,p.ProcessName,p.WorkingSet64 });
I want to iterate in to result
foreach(process in result) ...
Hello all.
I have the following that pulls through a list of suppliers:
public List<tblSupplierPerformance> GetSupplierInfo(string memberid, string locationid, string supplieridname)
{
MyEntities suppliers = new MyEntities();
var r = (from p in suppliers.tblSupplierPerformances
where p.MemberId == memberid && p.Lo...
I have a document generator which contains queries for about 200 items at the moment but will likely be upwards of 500 when complete. I've recently noticed that some of the mappings denote lazy loading. This presents a problem for the document generator as it needs access to all of these properties based on which document is being genera...
I'm using a LINQ query to translate data inside a DataTable object to be a simple IEnumerable of a custom POCO object.
My LINQ query is:
Dim dtMessages As DataTable
'...dtMessages is instantiated ByRef in a helper data access routine... '
Dim qry = From dr As DataRow In dtMessages.Rows
Select New OutboxMsg...
Hello,
I'm databinding a radiobuttonlist with a LINQ query like so:
var query = from m in Db.Udt_Menu
orderby m.Name
select m;
this.radMenuSelection.DataValueField = "menuID";
this.radMenuSelection.DataTextField = "name";
this.radMenuSelection.DataSource = query;
this.radMenuSelection.DataBind();
However, when i wa...
I'm having a problem when I attempt to create a generic List using a POCO within a LINQ query that creates another POCO:
var user =
from u in ctx.users
select new User
{
id = u.UserID,
name = u.Name,
roles = u.Roles.ToList()
};
I have created both a User and Role class. If I define 'roles' in User as:
public List<Roles> r...
Hi,
Scenario: I have a list and three search filters.
Something like:
ResultList = OriginalList.Where(filter1).Where(filter2).Where(filter3);
Question: Can I update filter 3, and then have the ResultList update, without having LINQ running filter1 and filter2? (I want to improve performance)
Basically, it would be the same as:
Re...