I am returning IQueryable<Customer> to the other method for some querying operations. The return method looks like:
return from cust in _dbCustList
select new Customer
{
CustomerId = cust.Customer_Id,
FirstName= cust.First_Name,
LastName= cust.Last_Na...
I'm playing around with Subsonic 3.0 SimpleRepository and try to get menus and menuitems with one linq query, but the menuitems is allways null
Menu
public class Menu
{
public Menu()
{
MenuId = 0;
MenuName = "";
MenuItems = null;
}
public int MenuId { get; set; }
public string MenuName { get;...
Hi there,
I written a small query and in Linqpad its working well but (see below) Tariffs is not returned as Iqueryable, does anyone know how to fix this ?
Basically see Tariffs = new ....,
from v in House
join gvt in
(from t in MyTariffs where t.Id == 3 select t)
on v.IdTariff equals gvt.Id
select new
{
Id = v.Id,
Tariffs =...
I've used this in the past to build comma seperated lists:
var list = new List<int>{1,2,3};
var retVal = list.Select(i=>i.ToString()).Aggregate((a,b) => a+", "+b);
Works great.
I'm trying to do the same sort of thing to 'wrap' each element as an xml node.
Something like:
Aggregate((a, b) => string.Format("<ID>{0}</ID><ID>{1}</ID>",...
I'm working on a Refresh() extension method for ObservableCollection which adds, removes or replaces items based on a matching key (this means when bound to a DataGrid the grid doesn't re-scroll and items don't change their position unless they were removed).
Problem is when I replace items in the ObservableCollection the last item thro...
I am using subsonic 3. in my case:
Entity Class :
public class Org: IActiveRecord
{
public string fieldA
{get;set;}
public string fieldB
{get;set;}
}
and in my linq query:
var linqNodes = from o in DB.Orgs select new TreeNode{ id=o.fieldA,text=o.fieldB};
var nodes = linqNodes.ToList();
the TreeNode class is my custom class for ...
Hello all,
I am using c#.net
I have a Grideview on my screen and need it to allow paging.
Source Code
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
<Columns>
<asp:BoundField DataField="appID" HeaderText="appID" SortExpression="appID" />
</Column...
Hi,
I have an 3-layered project, so that all Linq-Querys himself are in the DAL.
Now I have a filter function implemented in the Desig-Layer and want easily filter there, but how?
Business.UserHandling uh = new Business.UserHandling();
List<DAL.Benutzer> users = uh.GetUserOverview();
gridUserOverview...
Having been given the all clear to move code from my Page_Loaded method to the constructor (See HERE), i am now encountering errors on my Linq to entities query. It is now causing a nullreferenceexception and i can't figure out why at the moment. See below for the exception location.
public Building()
{
InitializeComponent();
l...
What is PLinq? And what is the difference between this and the normal Linq? I saw this word many times, so I googled it and found that it is a new .NET Framework 4 feature, but I didn't really understand what it is...
Thanks.
...
I can seem to get any records from the following xml.
xmlns="http://www.w3.org/2005/Atom"
If i remove the above it works
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
<entry><id><![CDATA[text]]></id><
author><name><![CDATA[film24]]></name></author><t...
How can this LINQ query expression be re-expressed with extension method calls?
public static List<Tuple<int, int>> Concat()
{
return (from x in Enumerable.Range(1, 3)
from y in Enumerable.Range(4, 3)
select new Tuple<int, int>(x, y)).ToList();
}
...
Hi there,
How can i do this query with Linq To Entities
SELECT * FROM TableA
WHERE MyID IN
(
SELECT MyID
FROM TableB
)
The thing is that TableB does not exist as an entity because it contains only foreign keys to other tables, and there is no direct link between TableA and TableB
...
I´m using a Wcf service and in the data access layer I use this code:
public BindingList getPeople(s)
{
IQueryable<Personal> query;
EntidadesDataContext dc = GetDC();
DataLoadOptions loadOptions = new DataLoadOptions();
loadOptions.LoadWith<People>(pp=> pp.PeopleDepartment);
loadOptions.LoadWith<PeopleDepartment>(pd=...
How can I see the XML output of following C# code? I can see that it uses XElement, but where I can locate the XML file or the output?
private void Form1_Load(object sender, EventArgs e)
{
XElement doc = new XElement("searchresults"); // root element
//create
XElement result = new XElement("result",
...
Hey,
in my DAL I have 3-5 Lists of something:
List<User>, List<Items>, List<bla>
Now I want to modify these Lists generic in a method.
How can I write a method with parameters allowed of all of this? (I tried var but don't allowed in the method head)
P.s.: Don't care about type, I will cast it back easily:
List<User> user; user = ...
We normally follow coding / naming standard for all C# syntax. For Example, if we declare string inside the method, we use Scope-datatype-FieldName format. (lstrPersonName)
List<Person> icolPerson;
private LoadPersonName()
{
string lstrPersonaName;
}
i am kind of thinking how do we follow the naming standard in Lambda Expression. E...
Using SQL Server 2005 I've run a query like this
SELECT * FROM mytable WHERE (LEFT (title, 1) BETWEEN @PREFIXFROM AND @PREFIXTO)
I use this to do alphabet filtering, so for example
PREFIXFROM = a
PREFIXTO = c
and I get all the items in mytable between a and c (inclusive)
How do I do this in linq?
Selecting all the records fine.. bu...
how can I create a dynamic lambda expression to pass to use in my orderby function inside linq? I basically want transform "queryResults.OrderByDescending();" in "queryResults.OrderByDescending(myCustomGeneratedLambdaExp);" where myCustomGeneratedLambdaExp shall be a string containning "x => x.name"
Thanks
...
I can think of a million ways to do this, but none seem very elegant. I wonder if anyone knows a neat way to move an item of say id=10 as the first item in a list using LINQ (or whatever really)
Item A - id =5
Item B - id = 10
Item C - id =12
Item D - id =1
In this case how can I elegantly move Item C to the top of my List?
This is t...