LINQ Part II Easy Sorting

With Linq you can easy create Sorting Delegates
Instead of writing the delegates the old way :

1
  pers.Sort(delegate(Person p1, Person p2) { return p1.Name.CompareTo(p2.Name); });

You can also write it with Linq this way:

1
   pers.Sort((o1, o2) => o1.Name.CompareTo(o2.Name));

It is Easier to use and to remember,and its also written faster.
There is no argument left for not using this, even its as fast as the old way:
(you can download the dem and check it for your self)

This is the Person Class for reference
you can also download the sample:
LinqExample

1
2
3
4
5
6
7
8
9
10
11
12
13
public class Person
{

public int Age { get; set; }
public string ForeName { get; set; }
public string Name { get; set; }
public Person(string Forename, string Name, int Age)
{
this.ForeName = Forename;
this.Age = Age;
this.Name = Name;
}
}

Nice Tool / Plugin for Visual Studio 2008 / 2010 Setting Regions

Hello,
i found a nice Tool for Setting regions in Visual Studio ( regionerate ).
So its easy to establish Rules / Code Conventions for Regions,
in you company.(its easier to find something if you know where you can find it)

See this Example:
You can Set Regions with right click:

result

nice Features ( doubble Click the cube)

FeelFreToDonate

Everything is included in regions

Regionerate this

You can get it here:

GetLink

Problem with the SPSiteDataQuery Sharepoint Computed Field

Today we found a problem under Sharepoint 2007 with querrying Computed Fields.

We tried to get the LinkTitle with SPSiteDataQuery and also the FileLeafRef
within one querry for a generic List

But as result Sharepoint delivers only a Date ( Modified Date),we could not find
the Problem first, and tried the same with a differend order of the Viewfields, and it works !?

Then we tried the same for LinkFilename an found out that the CAML behavior varies with the order
of the Computed Fields in the Viewfields:

Example:

Query for a Document Library:
SPSiteData Query:

<Where><Gt><FieldRef Name=”ID”/><Value Type=”Counter”>0</Value></Gt></Where>
ViewFields:
<FieldRef Name=’LinkFilename’/>

Result:

LinkFilename Normal Query

So if we we got all results that we expect, whithout querring any other field !

Next Query:

Query for a Document Library:

SpSiteData Query:

<Where><Gt><FieldRef Name=”ID”/><Value Type=”Counter”>0</Value></Gt></Where>

ViewFields:

<FieldRef Name=’LinkFilename’/>
<FieldRef Name=’ LinkFilenameNoMenu’ />

Then we got this Result:

ViewField test 2

This is absolutely correct, so we normaly don’t need to querry all Fields on that the computed Field depends
But when we change the order of the Viewfields:

Query for a Document Library:

SpSiteData Query:

<Where><Gt><FieldRef Name=”ID”/><Value Type=”Counter”>0</Value></Gt></Where>

ViewFields:

<FieldRef Name= ‘LinkFilenameNoMenu’ />
<FieldRef Name=’LinkFilename’/>

We get a result within the Table that we did not Expect

004ViewFields

So The Link file ame changes its Value when other Computed Fields are requestet, for example

we take a 3rd Viewfield and Change to Order:

005ViewFields

Now again all Fields Changed Their Value, even the LinkFilenameNoMenu, LinkFilename has the same Values as

LinkFilenameNoMenu.

The solution is still not found:

Social MSDN

We have to Query the Fields :

<FieldRef ID=”{3c6303be-e21f-4366-80d7-d6d0a3b22c7a}” Name=”_EditMenuTableStart”/>
<FieldRef ID=”{2ea78cef-1bf9-4019-960a-02c41636cb47}” Name=”_EditMenuTableEnd”/>

To get the Correct result:

Solution1

but this does ot work with other computed fields:

I tried to set viewfield “_EditMenuTableStart at the beginning of each query, but it does not work
the brings the columns into disorder even if i querry all the fields
that are referenced in the fields.xml( like purposed in the msdn article). So we need here a solution soon, that seems to be a
sharepoint bug, through that we get information about columns that we did not request for example a date as a title…

How to Install a WSS / MOSS 2007 language pack correctly

this example is for the english language and for WSS / MOSS 64 bit.
you can change the language via the ms downlaod site. For WSS you only need step 1 and 3.

1)WSS Language Pack

2)MOSS Language Pack / image only

3))WSS Language Pack Service Pack 2

4)MOSS Language Pack Service pack 2

Image Extractor: Deamon Tools Lite

Why i love LINQ : Part I

For me, LINQ is one of the most powerfull features of .net. I dont like to advise you, maybe you still know about LINQ but never used it.

It helps me to save time during dvelopment and as you may know time is money!

Instead of iterating memeberwise through collections you only have to write a single line of code.

Linq.Part1jpg

web.config debugging information

WSS / MOSS  normally provides error messages intended for end
users.  Modifying web.config enables debugging support and error messages
that contain more information(stack trace).

I’m posting this so that I can always find it when I need it.

<configuration>

<SharePoint>

<SafeMode CallStack=true />

</SharePoint>

<system.web>

<customErrors mode=Off />

<compilation debug=true />

</system.web>

</configuration>

Problem with the query of Sharepoint Calculated Fields ?

Do you have Problems with the SPSiteDataQuery (CAML) query  of Sharepoint
computed Fields. You are running in an Error or recive an empty DataTable ?
Normaly you think your query must be  correct because it looks  exactly like this:

<Query>
 <Where>
   <Eq>
     <FieldRef Name='MyComputed' />
     <Value Type='Computed'>111</Value>
   </Eq>
 </Where>
</Query

Haha, yes my friend, you are realy not alone with this problem on the planet.

It seems to be the logical solution for the correct caml querry,
but the value type is saved in the format it is determined
in the Computet Field, So  is the field of the Type Text, or Integer ?
Than the query must look like this:

<Query>
 <Where>
   <Eq>
     <FieldRef Name='MyComputed' />
     <Value Type='Number'>111</Value>
   </Eq>
 </Where>
</Query>

You can get the correct ValueType of the field with -> ((SPFieldCalculated)field).OutputType.ToString();

Please also note this. The Value defined for the coloumn has to match the ValueType that is expected with the formula !

For Example: The Result of (Column1+Column2)  is interpreted by Sharepoint as Number
so the ValueType must be Number
For Example: The Result of =Concatanate([Column1][Column2])  is interpreted by Sharepoint as Text
so the ValueType must be Text

Welcome

Hello Sharepoint freaks, welcome to my little

corner, hope you enjoy the posts and write back if you

found a nice solution or something interesting

Get Adobe Flash playerPlugin by wpburn.com wordpress themes