Trying to "thaw" serialized objects that have been stored in an XML file:
In LinqToSQL, I can (with a suitably decorated class) do this type of thing:
[Table(Name="Plants")]
public class Plant
{
[Column(Name = "Id", IsPrimaryKey = true)]
public int Id { get; set; }
[Column(Name = "Genus")]
public string...
Possible Duplicate:
Puzzling Enumerable.Cast InvalidCastException
Hi,
I just noticed something quite strange with the Enumerable.Cast<T> extension method... It seems that it can't cast from int to long, even though this cast is perfectly legal.
The following code fails with an InvalidCastException :
foreach (var item ...
I have 3 tables, Customer, Surfboards, and CustomerSurfboards. CustomerSurfboards is the Joiner table.
Customer CustomerSurfBoards Surfboards
---------- ------------------- ------------
CustomerID CustomerSurfboardID SurfBoardID
IsActive CustomerID
SurfboardID
I want to select all surfboards ...
Dictionary<DateTime, int> data1
Dictionary<DateTime, int> data2
not sorted
if the dates in data1 is from **1/1/2000 - 1/1/2009**
and the dates in data2 is from **1/1/2001 - 1/1/2007**
then both Dictionaries<> should have the date ranging from **1/1/2001 - 1/1/2007**
it could be the other way around.
bascailly i need to remove the...
I'm trying to do a Linq GroupBy on some objects using an explicit key type. I'm not passing an IEqualityComparer to the GroupBy, so according to the docs:
The default equality comparer Default is used to compare keys.
It explains the EqualityComparer<T>.Default property like this:
The Default property checks whether
type T i...
hi i have an xml like this
<?xml version="1.0"?>
<DataSetExchangeWMS xmlns="http://tempuri.org/DataSetExchangeWMS.xsd">
<dtObjektInfo>
<LanguageCode>1031</LanguageCode>
<LiegenschaftID>7463</LiegenschaftID>
</dtObjektInfo>
1040
7463
09
Now as i learned from tutorial i get my xml file and select nod...
I'm working on a legacy where some fields uses special encodings. Is it somehow possible to set an decode the fields in the linq instead of doing as I'm doing now:
XisoEncoding enc = new XisoEncoding()
var q = from b in ent.Basket
where b.ID == 22038
select b;
Basket basket = query.First();
basket.STOMAN_MESSAG...
I just cannot get this to work, would appreciate if someone can help.
So I get back an XML result from a database which looks like:
<matches>
<issuer client_name="MTR" score="6" match_list="MTR CORPORATION LIMITED"/>
<issuer client_name="PEOPLE''S REPUBLIC OF CHINA" score="4"
match_list="DEMOCRATIC PEOPLE'S REPUBLIC OF KO...
Hi ! I'm trying to transform the SQL Query below into Linq to SQL
select Categorias.IdCategoria, Categorias.Nome, SUM(lancamentos.valor)
from lancamentos
left outer join Categorias on Lancamentos.IdCategoria = Categorias.IdCategoria
where Month(DataLancamento) = 11
and Credito = 1
and Lancamentos.Ocultar = 0
group by Categorias...
I have a FormCollection and I just want to only iterate through the keys the do not contain the string pricing.
So what I tried was this...
foreach (var key in collection.AllKeys.Where(k => !k.Contains("Pricing"))){ ... }
The problem is the return is not a filtered list its returning boolean values... in which in need the filtered li...
I've stored 30,000 SimpleObjects in my database:
class SimpleObject
{
public int Id { get; set; }
}
I want to run a query on DB4O that finds all SimpleObjects with any of the specified IDs:
public IEnumerable<SimpleObject> GetMatches(int[] matchingIds)
{
// OH NOOOOOOES! This activates all 30,000 SimpleObjects. TOO SLOW!
...
What's the simplest way to code against a property in C# when I have the property name as a string? For example, I want to allow the user to order some search results by a property of their choice (using LINQ). They will choose the "order by" property in the UI - as a string value of course. Is there a way to use that string directly ...
How can I produce this query using NHibernate.Linq?
WHERE this_.Name LIKE @p0; @p0 = 'test' // Notice NO % wild card
Note, this is not Linq To Sql or Entity Framework. This is NHibernate.
Edit:
Here is the desired query using ICriteria:
criteria.Add(Expression.Like("Name", "test"));
return criteria.List<Theater>();
...
Suppose I have 3 tables: A(aid, ...), B(bid, ...) Relationship(aid, bid, ...)
Then I have a aid as parameter, I want to get the result from b. If use SQL, will be like
select b.* from B join Relationship on b.bid = Relationship.bid
where relationship.aid = aid_param
how to write linq with same result as above SQL. (the foreign key was...
Hi,
My Database contains 4 tables:
TABLE TBLCARTITEM (CART_ID, ITEM_ID, PROMOTION_ID, many more cart item fields)
TABLE XREFCARTITEMPROMOTION (CART_ID, ITEM_ID, PROMOTION_ID)
TABLE TBLPROMOTION (PROMOTION_ID, PROMOTION_TYPE_ID, many more promotion fields)
TABLE TBLITEM (ITEM_ID, many more item fields)
The XREFCARTIEMPROMOTION table ...
Hi,
When using Linq2sql everything automagically works. My experience is that going with the flow is not always the best solution and to understand how something internally works is better so you use the technique optimally.
So, my question is about linq2sql.
If I do a query and get some database objects, or I create a new one, someho...
Optimally I would like linq to use X database connections instead of 1 to speed things up.
The only way now is to open X connections, and create X databasecontexts, and associate them.
It would be easier if somehow I could tell linq to use X connections.
Is this possible? Or is there another way to speed up database queries?
thanks
e...
Lets say you have an XML like like this:
<data>
<messages>
<message name="Person" id="P">
<field name="FirstName" required="Y" />
<field name="LastName" required="Y" />
<field name="Sex" required="N" />
</message>
<message name="Car" id="C">
<field name="Make" required="Y" />
<field name="Model" required=...
I remember seeing a link about it here where some people claimed it's 1000 times faster than the BCL Linq.
Anyone used it here? Is it true?
Also is Microsoft's PLinq gonna be along the same lines? Because it seemed to me like the above mentioned Linq was automatically parallel or something.
And if that's the case, why isn't Microsoft ...
Here is a simplified version of the code I use:
class Program
{
// Here is the ugly stuff
static void DoStuff(int[] uidArray)
{
int chunkCount = (int)Math.Ceiling(uidArray.Length / 10d);
for (int i = 0; i < chunkCount; i++)
{
// calculating the remaining uids.
// this is super...