is there a better way to do this kind of thing:
var filter = new CashFilters();
var element = XElement.Parse(request.OuterXml);
var productId = element.Elements("ProductId").Select(el => el);
if (productId.Count() == 1)
filter.ProductId = Convert.ToInt32(productId.Single().Value);
...
In a LINQ to SQL statement I've got a column name in the database that's also a C# keyword (void). How do I get the compiler to treat this as an object property and not the keyword?
I could re-write this in with the method notation, sure, but there's got to be a way to give the compiler a hint here...
var p = from c in mytable
...
I have this code snippet where we get a collection from COM Dll
public BOCollection SelectedObjects{
get
{
IMSICDPInterfacesLib.IJMonikerElements oIJMonikerElements;
oIJMonikerElements = m_oIJSelectSet.Elements as IMSICDPInterfacesLib.IJMonikerElements;
BOCollection oBusinessObjects = new BOCollection(oIJMonikerElements);
...
I am working on building some pseudo-intelligent caching into a LINQ query provider. What I'd like to do (ideally) is use the expression tree of a given query as the cache key in some scenarios. However, I don't want to store the entire object graph itself, so what's a quick way to get a hashsum-like value from an expression tree? Or if ...
Grettings!
I have some XML that looks like this:
<Root>
<SectionA>
<Item id="111">
<Options>
<Option val="a" cat="zzz">
<Package value="apple" />
<Feature value="avacado" />
</Option>
<Option val="b" cat="yyy">
...
How do you map a table called category with Id as Primary Key which has self reference called ParenCategoryId using LinqToEntity?
...
I am working on a webservice where we use LINQ-to-SQL for our database abstraction. When clients use our webservice, the objects are serialized to XML and all is dandy.
Now we wish to develop our own client that uses the native data types since there's no reason to do objects->xml->objects. However, from what I understand you can't tran...
Hey there I got a problem with my code, I compared three ways of implementing a query on a database
Standard SQL Query (From * Select ...)
LinQ Query
Precompiled LinqQuery (CompiledQuery)
Now the result I got is that the Precompiled LingQuery is 5 times faster than the LinQ Query but much more interesting ist that the Standard SQL Q...
Currently to me, LINQ is just a loose and amorphous cloud of concepts, usually about data access but also in combination with lambda expressions, delegates, anonymous functions and extension methods, it is about string and collection manipulation, so I want to pin it down.
When I write the following code, can I say I am "using LINQ" or ...
LogParser isn't open source and I need this functionality for an open source project I'm working on.
I'd like to write a library that allows me to query huge (mostly IIS) log files, preferably with Linq.
Do you have any links that could help me? How does a program like LogParser work so fast? How does it handle memory limitations?
...
I'm in need of a datastructure that is basically a list of data points, where each data point has a timestamp and a double[] of data values. I want to be able to retrieve the closest point to a given timestamp or all points within a specified range of timestamps.
I'm using c#. my thinking was using a regular list would be possible, wher...
I am trying to write an extention method for a repository. The repository has a method IQueryable<parent> GetAll(). I want to create an extention method FilterByChildId(int childId) so that I can write:
List<parent> data = from d in repository.getAll().FilterByChildId(33).ToList()
Not sure how to do the join on the parent and child i...
I receive a DataTable from excel file and data in the first Column looks like this:
11129
DBNull.Value
29299
29020
DBNull.Value
29020
I'm using LINQ to select distict and it works if there are no DBNull.Value values as below.
albumIds = dt.AsEnumerable().Select(p => (int)p.Field("F1")).Distinct().ToArray();
But if DBNull.Value p...
I have a table with a datetime field. I want to retrieve a result set grouped by the month/year combination and the number of records that appear within that month/year. How can this be done in LINQ?
The closest I've been able to figure out is in TSQL:
select substring(mo,charindex(mo,'/'),50) from (
select mo=convert(varchar(2),mont...
Is there anyway to determine if a value is passed as a reference, eg. x.Age or a specific value. eg. 20 like so.
value(x => x.Age)
or
value(x => 20)
Cheers
...
I've seen time and time again API (particularly in the .NET framework) that uses Func<TObject, bool> when Predicate<TObject> is seemingly a perfectly responsible option. What good reasons might an API designer have for doing so?
...
I'm new to JQuery,
but as a follow on from my previous question regarding duplicated entries to the database, on a forum type application, the question is:
Is JQuery a good solution to show to the user, transaction progress, state of submit etc
And what is the best solution, if using JQuery
Else what other solution is right.
With a vie...
Hi,
I'm creating a page that uses Linqfor data access and I'm using DataList to display data. How can I use Linq to do data paging ? Please read simple code below :
I normally use a PagedDatasource but this only seems to work with a DataTable.
Here's my Linq to return Datatable which is bound with Datalist :
Public Shared Function ...
I'm using Linq2Sql with pipes/filters. My database consists of Accounts and Transactions tables where each Transaction row is linked to an Account.
When displaying an Account I want to show the Account with all its Transactions. Simple enough. Now I am trying to limit the transactions that are shown by /accounts/4/{year}/{month}/{day} f...
Using JAXB in Java it is easy to generate from a xml schema file a set of Java classes that xml conforming to that schema can be deserialized to.
Is there some C# equivalent of JAXB? I know that Linq can serialize and deserialize classes to/from xml files. But how can I generate C# classes from xml schema file and then use this classes ...