Contents tagged with tutorials
So it turns out the simplest way to update your dbml schema is to just delete the existing files and recreate them with SQL Metal. Then, when you include the updated dbml file in your VS 2008 project you will get new dbml.layout and .designer.cs files. You'll of course have to reset your layout if you've modified that. If you do this, you're safe. If you need that layout, continue reading.
Just regenerating the file with SQL Metal will overwrite the dbml file but it will not touch the other two files. This means your layout will be ok but you're not out of the woods. If you have changed the name of an object in the underlying structure, your layout will remove that object from the layout and place the newly named object in the default position (usually top left). This object will NOT appear in your intellisense because the .designer.cs file still has the old name. Note that code referencing the old object name will still compile and run but will throw a SQL object not found exception when run.
Error Code: -2146232060
Error Message "Invalid object name 'your object name'."
Error Number: 208
So you still want to refresh the schema and keep you designer layout? You have an easy option:
Exclude the dbml file from your project (automatically excludes the other two files).
Delete the .designer.cs file.
Rerun your SQLMetal command.
Re-include the dbml file.
Now the .designer.cs file is regenerated from the dbml and all intellisense and compile-time checking will work. The .cs file contains all the appropriately named items. You also still have your original designer layout but any new objects are placed in the default location and old objects have been removed.
Now if you're modifying your dbml by adding associations etc., you are going to need a compare tool. I use ScooterSoftware's Beyond Compare. Simple, cheap and reliable. Generate your dbml file to a different location and run the compare utility to "import" all your modifications to the new file. Then perform the steps listed above.
SQLMetal.exe is the command line tool that will allow you to very quickly spin up the object model you'll need to connect from your SQL Server database via Linq. Here are the basics of using SQLMetal.
Take a look at this text file, the output from executing SQLMetal.exe from the VS 2008 command prompt with no parameters. It's pretty straight forward but knowing the details ahead of time will help you set yourself up properly.
This database contains a relational dataset with a few tables, a simple DML stored procedure, a view, a table-valued UDF and a scalar-valued UDF. In my next posting we'll look more deeply at what you can do with these kinds of objects and how to properly address them.
SQL Metal Commands
The following commands will be executed to show you what we've got. Here is the actual text of what I ran for each example. (The commands are formatted for easier reading. When actually executing, everything should be on one line.)
1. Create an xml file in dbml format but without an extension so you can peek at it in VS without it opening a designer.
2. Create a basic dbml file to view and manipulate in the VS designer.
3. Same as #2 except with the pluralize switch to see what that looks like.
4. Make the classes generated serializable and include functions, views and stored procedures.
5. Create just a code file, no designer.
6. Create a code file and a mapping file but no designer.
I created new file output names, namespaces and datacontext object names for each example. This allows me to have all of them in the same project at the same time. If I think of it and have time, I'll fire some Linq code up for each example and see what kind of IL is generated for each. I expect it to be the same but it would be nice to know for sure.
When you create a dbml file, only that file is created by SQL Metal. Opening or including file in VS 2008 will then create the .layout and .designer.cs files necessary to lay it out. This is great because you can make your layout nice and easy to understand and not have to worry about recreating it every time you have to regenerate the file. If you, like me, use SQL Server's data diagrams, you know the frustration of not knowing exactly when SQL Server will decide to 'rework' your layout for you. This is the file that I reformatted with example #2. Note the table-for-table matching with what's in the SQL database.
Pluralizing your model notes from MSDN: "When you use the /pluralize option with the Northwind sample database, note the following behavior. When SqlMetal makes row-type names for tables, the table names are singular. When it makes DataContext properties for tables, the table names are plural. Coincidentally, the tables in the Northwind sample database are already plural. Therefore, you do not see that part working. Although it is common practice to name database tables singular, it is also a common practice in .NET to name collections plural."
Here is an example of the output from using the /pluralize switch.
Tables, Views, Stored Procedures and Functions
Note here that including views, sprocs and functions will allow you to see views and operate on them like tables but it will not include table-valued functions in your layout although you can still use them as tables in your Linq queries. Here is a snip of that code:
var DueDates = from d in db.FnGetDueDates() select d;
dataGridView1.DataSource = DueDates;
To Map or Not
Next, the difference between creating a map file (#6) and not creating a map file (#5) are that not creating the map will force the tool to create an internal System.Data.Linq.Mapping.MappingSource object (concrete type of AttributeMappingSource), two additional constructors for the DataContext and will add attributes directly to all objects and properties as appropriate that will allow them to 'self-map' into the database. See the attached solution for details. By creating the mapping xml file, you take these items out the code file so that if you want to reset any of the mappings, you can. This is a bit closer to an abstraction model but not quite there in my opinion.
When you run the project, you'll get a button and a data grid. You can fire it up and see the customers in the list executed with only the connection in app.config. Pretty cool. No ADO.Net code or objects anywhere! You can also replace the Linq query and binding with what you see above and bind to a UDF.
In my next post, I'll spend some time showing how to address each type of object in different ways. Maybe we'll be populating collections or just directly binding to other bits and pieces of the UI that will of course have to expand a bit...
So the requirement presented to me for a client was to take an existing page layout and change a few of the properties to allow it to use some custom styles implemented at the site collection level. To do this, I needed to create a new page layout based on an existing layout, make this part of a feature and pull in all the bits and pieces necessary to deploy this as a feature. Finally, I had to deploy it to the client's testing environment.
Here is how I did it...
First, I was instructed that the Search Main Page was to be used as the starting point. A developer on my team told me the best way to go would be to load up SharePoint Designer, navigate to the appropriate document library and export the file. This didn't work. My requirement was to have the search web part already on the page, the same as the existing search main page. SharePoint Designer killed this web part tag so it came up empty.
Getting a copy of the page layout
1. Better is to go to the site collection you're starting with
2. Select "Site Actions" -> "Site Settings" -> "Modify All Site Settings"
3. Under "Galleries", select "Master pages and page layouts"
4. Find the page layout from the list and open its context menu, select "Send to" -> "Download a Copy"
5. Save the file to the solution location. We won't be using Visual Studio because its not necessary for this evolution.
6. Once the file is saved, reopen the context menu for the page layout file and select "View Properties".
7. Click on the Preview Image and when it appears, right click and save the image to the same location as the aspx file.
Now you have the basic aspx files you will modify and put back into SharePoint as a feature. Open the aspx page in an appropriate editor. I'm assuming you understand enough about aspx to do what you need to do. Make the appropriate modifications and save the file.
IMPORTANT NOTE: If you are like me, you have a desire to 'clean up' the file declarations so you can see what's going on. Don't do this. I haven't figured out why but when I introduced hard returns in the second line (the really long one) of declarations between <% %> sections, it bombed when I reimported it into SharePoint. A guy on the team here thinks there may be a checksum on that line to head off tampering. Dunno but I know when I leave it it works, when I touch it it bombs.
You can also use any editor (Paint.Net works) to change the page layout to look the way you want it to. Change the folder of this file to your feature folder + "\Images". It's required for the page layouts and master pages.
So you should have two files and a subfolder for your feature ready to go.
Now we need to set up the feature to deploy it.
1. Create two new files in any editor: "feature.xml" and "layoutfiles.xml"
2. Here are the contents of my feature.xml file:
Title="Custom Formatted Search Page Layout by Jim"
Description="Search page with customized style inclusions"
2.1. Id is a new GUID you generate from Visual Studio.
2.2. Scope means the level where this will be used, not the level at which it becomes available for items below it. So "Site" scope means it will be installed at the site collection level and used at the site level.
3. Here are the contents of my layoutfiles.xml file:
<Module Name="CustomSearchMain" Url="_catalogs/masterpage" Path="" RootWebOnly="TRUE">
<File Url="CustomFormattedSearch.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="$Resources:spscore,SearchMainTitle;" />
<Property Name="MasterPageDescription" Value="$Resources:spscore,SearchMainDescription;" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_welcomepage_name#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#" />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/Preview Images/customsearchpage.gif, ~SiteCollection/_catalogs/masterpage/Preview Images/customsearchpage.gif" />
<AllUsersWebPart WebPartZoneID="TopZone" WebPartOrder="1">
<Assembly>Microsoft.SharePoint.Portal, Version=188.8.131.52, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<Module Name="LayoutPreviewImages" Url="_catalogs/masterpage/Preview Images" Path="Images" RootWebOnly="TRUE">
<File Url="customsearchpage.gif" Type="GhostableInLibrary"/>
3.1. I took most of this from a coleague and from the net. The CData portion gives you the embedded web part already in the top web part zone.
3.2. Notice the gif image parts of the xml. These are whatever the new name is for the gif you edited earlier.
3.3. Notice also the part that says: "contenttype_welcomepage_name". This means that your layout will appear under the "Welcome Page" templates when you go to use it in your site collection. I haven't found much about this on the web yet but I believe if you search on content types and master page libraries, you may find additional options.
Your feature is complete!
Now its time to deploy.
1. Copy your aspx, gif (in its folder) and 2 xml files to the server where you want to deploy and into a new temporary folder.
2. Copy from the temp location to the 12 hive \Template\Features\ folder.
3. Open a command line and run: stsadm.exe -o installfeature -name MyNewPageLayoutFeature -force
3.1. Use the -force option if you've already installed previously.
3.2. the -name value is the name of the folder where the your feature now exists in the 12 hive.
4. Execute iisreset
5. Browse the the appropriate site collection on your server and back to "Site Actions" -> "Site Settings" -> "Modify All Site Settings"
6. Under "Site Collection Administration" select "Site Collection Features"
7. You should see your new feature/page layout. Click to activate.
Use your new layout.
Now, when you go to create a new page, you should see your additional layout. When you select it, you should get your custom layout gif to show users what it will look like.
I can imagine really intricate uses of this for creating custom CRM dashboards or for magically including SilverLight applications in your system. Good Luck!
I found this a week or so ago, lost it and then found it again. At only 29 minutes, its an ideal starter for a develper with my background to create, deploy and activate a feature for a site or site collection. Well spoken and concise with a lot of bits and pieces described in just enough detail to get you working.
I'm currently working on getting a new page layout into the "12 Hive" via a feature. When I have it nailed, I'll post a how-to.
I started looking into this guy a week or so ago and have been very impressed with the volume of training info he is either responsible for or finds. I haven't gotten too deeply into any of it yet but it seems pretty well targeted for what I'm doing these days.
In my current position, it always helps to take a small step back and do something else for a little while. I'm working on a simple problem involving building a reporting services report (SSRS) from a SharePoint task list. It will involve building the report against a dataset that was created programmatically. I've looked and can find no secure way of reporting directly against a list of data within the current user's context. Once complete I'll post how I did it. That's not the problem.
The problem is that I could not see the reporting services web sites after setting them up using the SSRS configuration manager UI. It said they were there but I couldn't get to them. So, since I'm doing a brief 15 minute intro to data abstraction next month at a local user group, I figured I'd fire up the latest Beta of the VS 08 VPC and dink with EDM for a while. I only got as far as extracting the VHD's before I fell asleep so more on that later too.
So, firing back up my MOSS dev VHD this morning I looked back at IIS and realized that the "normal" installation of MOSS involves stopping the default web site. Looking into the default web site I find the ReportServer and Reports web apps. Duh!
So I went back to SSRS Config and put them under the Portal web site. Then I get this:
- Parser Error Message: Cannot use 'partitionResolver' unless the mode is 'StateServer' or 'SQLServer'.
Whoops. A quick Google and a this forum post led me to believe there was a conflict with MOSS.
So, I'd recommend doing the following when you're firing up SSRS on a MOSS box, at least in a development environment. (Caveat Emptor)
Create a new virtual directory off \inetpub\wwwroot\
Configure (in SSRS) a new "Report Server Virtual Directory"Configure (in SSRS) a new "Report Manager Virtual Directory"Go wo Web Service Identity and click the New button next to Report ServerCreate a new App Pool for RS to run within
Give it a specific port number
I used RS / 8090
Set the authenticated user for the new app pool to the SQL Server Service account you used to set up MOSS.
I used ReportingServicesAppPool
Set Report Server and Report Manager to the new app pool and click Apply
This should have all the SQL permissions you need to run SSRS (I hope...)
After making these changes I can go to the following URL's and get big love:
Now I can continue to configuring everything to actually use the Report Web Part. Hope this helps some.
Incidentally, what I'm hearing from the business community (faintly and very far away) is that BI, Agile Reporting and Custom Workflows are the pieces that really draw in the clients around here for SharePoint consulting engagements. Reporting seems easiest to me so off I go...
Joel Oleson, on the SharePoint Team Blog has posted a sample deployment plan for a MOSS installation. Looks pretty comprehensive.
At a glance:
- 6 Months
- Database Administrator
- Desktop Administrator
- Education/Training Lead
- End Users
- Intranet/Internet Administrator
- Project Manager
- Test/QA Lead
- Workspace Coordinators
- Overall methodology seems to be MSF-esque with phases:
- Deployment, Implementation and Configuration Management
- Post-Implementation Operations, Optimization and Business Review
They have clearly tried to make this all things to all deployments which is nice. I expect my shop will probably start out with this and whittle it down a little into something that looks like what we actually do. I think that we'll also set up some task notes or links within tasks to point to specifications and guidance.
Additionally, this does not cover anything related to significant custom feature deployments. I wouldn't really expect that though.
Overall, good stuff.
It seems that with Sharepoint and MOSS, Microsoft has either gone in a new direction with their documentation, they are just behind the power curve on getting documentation out there OR there is just so much to this product that they decided to let the community figure it out. So, in the interest of helping out, I will post tidbits that I'm learning about this product as I figure it out.
We just had a client ask to give a 10 minute overview of the recycle bin functionality of Sharepoint. Try as I might, Google came up short. I found bits and pieces in the forums but nothing so far has been a brief drive-by of the recycle bin functionality and how to actually use it. So here goes:
The recycle bin in Sharepoint is a 2-stage operation where the user can delete content and get it back for a configurable amount of time and then an administrator can get it back for a configurable frame after that. This you can find in all the help documentation. But how do you DO anything with it?
Use Level Recycle Bin
The first and most simple operation is just to click on the recycle bin link in the corner. Go to the list or content area where you deleted the item and click on the link. You should see the item if it hasn't exceeded its retention expiration date.
Administrative Level Recycle Bin (Site Collection Level)
If your item is not in the recycle bin or you can't find it in your content, ask an administrator to pull it from the site collection recycle bin.
To do this, click on Site Actions in the top right corner of the site and select Site Settings --> Modify All Site Settings.
On the next page, select the Recycle Bin link.
You can now select either all user's recycle bin items or the items that have been deleted from the user recycle bin.
Administering the Recycle Bin Retention Policies
So all the documentation talks about how an adminsitrator can change the retention policy for both the entire server and all users so lets look at how to do that.
Start by going to Administrative Tools in Windows. Select SharePoint 3.0 Central Administration. This opens the admin web site.
Select the Application Management tab.
Now, in the SharePoint Web Application Management section, click on Web application general settings.
Scroll all the way to the bottom of the next page and find the place to edit your Recycle Bin settings for the server.
You can turn off the recycle bins (not recommended), change the user level or the admin level recycle bin settings and then save your new values. What I'm not sure about is the quota in a multi-server setting primarily because I don't know where the recycle bin items are saved. If anyone knows, please post a comments. Thanks!
I believe that as you age in the software development business, you start realizing that there is very little new in the world. This means that for someone like me who doesn't read very fast and has kids who need shoes, the desire to go out and purchase a new 60 dollar book about the latest technology wanes somewhat. The problem is that half the book is philosophy and half the other half is basic stuff I already knew anyway. Culling through a myriad magazine and internet articles presents the same problem though admittedly without the expense. The authors are often not interesting enough to really keep my attention and the subject matter is frequently a rehash. I long for a diagram that shows me the lay of the land and allows me to just pick out what I want to learn, learn it and move on at my own pace and in my own direction.
This from the guy who wants to write professionally...
The MOSS technologies are really a jump forward in my opinion for MS. They offer integration points that "the smart people" are still trying to get their minds around and the products are useful right out of the box. Its like having your own Transformer! What I'm hearing from a lot of people on my team and others, though, is that the ability to actually dig in and code against this beast is limited by documentation. I have to admit, before this morning I got more information from blogs and forums than from any technical articles or books.
HINT: MOSS and Sharepoint are lumped under Office in MSDN!!
So I dug around the Office area of MSDN for about 11 seconds and found the Microsoft Office Interactive Developer Map. This is a really cool, easy to follow WPF application! It's available via ClickOnce and gives me both the overview I need to constantly review where I am and the details to let me dig into a piece within context.
I reallly hope that similar applications are put forth from MS for Visual Studio Team Systems, Exchange, SQL Server and some of the other platforms that have a very high knowledge entry bar.