<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Rockford Lhotka</title>
  <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/" />
  <link rel="self" href="http://www.lhotka.net/weblog/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2008-09-05T11:01:27.2738368-05:00</updated>
  <author>
    <name>Rockford Lhotka</name>
  </author>
  <subtitle>Author of Expert C#/VB 2005 Business Objects</subtitle>
  <id>http://www.lhotka.net/weblog/</id>
  <generator uri="http://www.dasblog.net" version="2.0.7180.0">DasBlog</generator>
  <entry>
    <title>Funny Microsoft commercial</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/FunnyMicrosoftCommercial.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,839f5fed-870e-4ae1-bd71-24d800c879c7.aspx</id>
    <published>2008-09-05T11:01:27.2738368-05:00</published>
    <updated>2008-09-05T11:01:27.2738368-05:00</updated>
    <content type="html">&lt;p&gt;
If the goal of a commercial is to make you laugh, this totally fits the bill!!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.youtube.com/watch?v=uz6amk3P-hY"&gt;http://www.youtube.com/watch?v=uz6amk3P-hY&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=839f5fed-870e-4ae1-bd71-24d800c879c7" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>UnitDriven visual enhancement</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/UnitDrivenVisualEnhancement.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,a003b20e-722c-49d4-90e4-be54a407dff7.aspx</id>
    <published>2008-09-03T09:34:23.9378416-05:00</published>
    <updated>2008-09-03T09:34:23.9378416-05:00</updated>
    <category term="Silverlight" label="Silverlight" scheme="http://www.lhotka.net/weblog/CategoryView,category,Silverlight.aspx" />
    <content type="html">&lt;p&gt;
As part of the &lt;a href="http://www.lhotka.net/cslalight"&gt;CSLA Light&lt;/a&gt; project we
created a unit testing engine for Silverlight and donated it to the community as &lt;a href="http://www.codeplex.com/UnitDriven"&gt;UnitDriven&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
We now have our first community contribution to this open-source project, in the form
of a really nice visual change. Here's the author's blog post on the topic:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://staxmanade.blogspot.com/2008/08/unitdrivens-ui-gets-minor-makeover.html"&gt;http://staxmanade.blogspot.com/2008/08/unitdrivens-ui-gets-minor-makeover.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Thank you Staxmanade! This is a really nice visual upgrade, and more importantly a
major usability upgrade. I love it!
&lt;/p&gt;
&lt;p&gt;
The next release of the CSLA Light unit tests will be linked to the new version of
UnitDriven, and having used it for just a day or so, I can say it is a big help.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=a003b20e-722c-49d4-90e4-be54a407dff7" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>CSLA Light and CSLA .NET 3.6 Labor Day pre-release</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/CSLALightAndCSLANET36LaborDayPrerelease.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,04faa89e-a25e-4199-9095-47361bdeee60.aspx</id>
    <published>2008-09-01T20:41:08.0793664-05:00</published>
    <updated>2008-09-01T20:41:08.0793664-05:00</updated>
    <category term="CSLA .NET" label="CSLA .NET" scheme="http://www.lhotka.net/weblog/CategoryView,category,CSLA%2B.NET.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://www.lhotka.net/weblog/CategoryView,category,Silverlight.aspx" />
    <content type="html">&lt;p&gt;
I have put an updated pre-release online for download of both CSLA .NET 3.6 and CSLA
Light 3.6.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;CSLA .NET&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.lhotka.net/cslalight/download.aspx"&gt;CSLA Light&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
We're now at the point of focusing primarily on stabilization and limiting new features.
Changes at this point will be due to our testing and usage, and feedback we recieve
from the community.
&lt;/p&gt;
&lt;p&gt;
This pre-release should be reasonably stable, on both the .NET and Silverlight platforms.
Please give them a try and post in &lt;a href="http://forums.lhotka.net"&gt;the forum&lt;/a&gt; with
any issues you encounter. Thank you!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=04faa89e-a25e-4199-9095-47361bdeee60" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>CSLA .NET on DNR TV</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/CSLANETOnDNRTV.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,074f3a63-cb61-4efd-b560-233d26349619.aspx</id>
    <published>2008-08-27T08:03:12.6954608-05:00</published>
    <updated>2008-08-27T08:03:12.6954608-05:00</updated>
    <category term="CSLA .NET" label="CSLA .NET" scheme="http://www.lhotka.net/weblog/CategoryView,category,CSLA%2B.NET.aspx" />
    <content type="html">&lt;p&gt;
The second part of the DNR TV show covering CSLA .NET 3.5.1 is now online. Here are
links to both parts:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.dnrtv.com/default.aspx?showNum=116"&gt;Part 1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.dnrtv.com/default.aspx?showNum=120"&gt;Part 2&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
As always, you can download CSLA .NET &lt;a href="http://www.lhotka.net/cslanet/download.aspx"&gt;from
here&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=074f3a63-cb61-4efd-b560-233d26349619" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>CSLA into the future</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/CSLAIntoTheFuture.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,41373c86-0f7c-44bc-8e12-4dc32e36728b.aspx</id>
    <published>2008-08-20T16:15:50.786-05:00</published>
    <updated>2008-08-20T16:21:41.7406816-05:00</updated>
    <category term="Books" label="Books" scheme="http://www.lhotka.net/weblog/CategoryView,category,Books.aspx" />
    <category term="CSLA .NET" label="CSLA .NET" scheme="http://www.lhotka.net/weblog/CategoryView,category,CSLA%2B.NET.aspx" />
    <content type="html">&lt;p&gt;
I've been thinking a lot about the future of CSLA and of .NET, and I'd like thoughtful
input.
&lt;/p&gt;
&lt;p&gt;
The .NET platform is, for lack of a better word, fragmenting. We have .NET, the .NET
client-only framework, .NET Compact Framework, Silverlight and probably others. All
of these are ".NET", but they are all different.
&lt;/p&gt;
&lt;p&gt;
CSLA will soon support .NET and Silverlight. It sort of supports the Client-Only Framework
now, but it was just pointed out to me that while it works, there are compiler warnings
in this scenario.
&lt;/p&gt;
&lt;p&gt;
For the past 6 or so years, I've been maintaining all my code twice, once in VB and
once in C#. This has never been fun, and wouldn't have been possible at all without
help from my colleague Brant Estes and from the &lt;a href="http://tangiblesoftwaresolutions.com/"&gt;Instant
VB and Instant C#&lt;/a&gt; tools. Even with this, the reality is that I have to do everything
twice, and test everything twice.
&lt;/p&gt;
&lt;p&gt;
(yes, I have a unified set of unit tests, but there's a ton of manual testing around
data binding in Web Forms, Windows Forms, WPF and now Silverlight that can't be automated)
&lt;/p&gt;
&lt;p&gt;
But now I'm faced with a truly horrific future scenario. CSLA .NET, CSLA Light, possibly
CSLA CF and CSLA Client-Only. Four versions of the framework. Two languages for each
version. Fixing a single bug requiring changing and testing 8 implementations.
&lt;/p&gt;
&lt;p&gt;
Clearly that's not realistic. Not only would it eliminate any fun, but it just isn't
practical. I doubt it would be practical even if I made CSLA a commercial product...
&lt;/p&gt;
&lt;p&gt;
Of course I can cut the complexity in half by maintaining the framework in only one
programming language. 
&lt;/p&gt;
&lt;p&gt;
This is a touchy thing of course. I was thinking Modula II, but I can't find a good
compiler for .NET... :)
&lt;/p&gt;
&lt;p&gt;
Seriously though, the clear choice would be to maintain the framework in C#, at which
point I run the risk of alienating the VB community. You might argue I should maintain
the framework in VB, but (for better or worse) that would almost certainly alienate
a much bigger constituency.
&lt;/p&gt;
&lt;p&gt;
The really important thing is that the framework would &lt;em&gt;support both VB and C#&lt;/em&gt;.
Regardless of what I do or don't do inside the framework, it can be used by either
language (and other languages for that matter) equally well. After all, most of the
.NET framework is written in just one language, yet it is used by everyone equally.
&lt;/p&gt;
&lt;p&gt;
Right now CSLA Light is only in C#, though I'm testing in both VB and C# to make sure
it supports both equally. I haven't tried, but I imagine you can use it from Ruby
or Python too, since both of those languages work in Silverlight too.
&lt;/p&gt;
&lt;p&gt;
Another alternative would be to solicit help from the community. For example, perhaps
one or more people would be willing to help keep the VB version of the framework in
sync over time. That has its own complications, but might be a worthy solution.
&lt;/p&gt;
&lt;p&gt;
This also ties into my book projects. I'm working on Chapter 16 of 21 for &lt;em&gt;Expert
C# 2008 Business Objects&lt;/em&gt; right now. As with the previous editions, most of the
book is focused on the design and creation of the framework itself, with less focus
on how to use the framework.
&lt;/p&gt;
&lt;p&gt;
I think a lot of people would actually prefer a book on how to &lt;em&gt;use the framework&lt;/em&gt;,
not caring so much how and why I implemented things internally. And I'd enjoy writing
that book (in VB and C# editions). But as it is, I'm looking at 2-3 months of work
to get CSLA .NET 3.6 working in VB (which will have to wait until the current book
is done), then a couple months to get the &lt;em&gt;Expert VB 2008 Business Objects&lt;/em&gt; book
done. That's 4-5 months where I could write a book on how to use the framework. Or
perhaps a series of highly focused ebooks. Or something along that line.
&lt;/p&gt;
&lt;p&gt;
I haven't reached a decision, I'm just thinking long and hard. Thoughtful input is
welcome, thanks!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=41373c86-0f7c-44bc-8e12-4dc32e36728b" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>Fall 2008 community events</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/Fall2008CommunityEvents.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,efbed349-ac2b-437b-a047-e92c962d44d7.aspx</id>
    <published>2008-08-19T14:43:30.5858992-05:00</published>
    <updated>2008-08-19T14:43:30.5858992-05:00</updated>
    <content type="html">&lt;p&gt;
&lt;a href="http://www.magenic.com"&gt;Magenic&lt;/a&gt; a couple fall community events they are
involved in organizing and/or sponsoring.
&lt;/p&gt;
&lt;p&gt;
In Chicago there's the &lt;a href="http://www.codeapalooza.com/"&gt;Codeapalooza&lt;/a&gt; event
coming up on September 6. This is sponsored by Magenic and will have speakers from
the whole community. It sounds like Justin Chase will be speaking at the event, talking
about &lt;a href="http://www.codeplex.com/UnitDriven"&gt;UnitDriven&lt;/a&gt; and the unit testing
issues we've been facing while building CSLA Light (Justin is on the CSLA Light dev
team).
&lt;/p&gt;
&lt;p&gt;
Then in Minneapolis there's the &lt;a href="http://www.twincitiescodecamp.com/TCCC/Default.aspx"&gt;5th
Twin Cities Code Camp&lt;/a&gt; on October 11. I'll be speaking at this event, talking about &lt;a href="http://www.lhotka.net/cslalight"&gt;CSLA
Light&lt;/a&gt; and &lt;a href="http://www.lhotka.net/cslanet"&gt;CSLA .NET&lt;/a&gt; 3.6. By that point
CSLA Light should be well into its beta phase and will be a lot of fun to show (and
see).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=efbed349-ac2b-437b-a047-e92c962d44d7" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>CSLA .NET ObjectFactory attribute</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/CSLANETObjectFactoryAttribute.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,f3a055cd-c027-4892-a263-505afbc12661.aspx</id>
    <published>2008-08-15T15:16:41.265-05:00</published>
    <updated>2008-08-15T15:17:08.0339552-05:00</updated>
    <category term="CSLA .NET" label="CSLA .NET" scheme="http://www.lhotka.net/weblog/CategoryView,category,CSLA%2B.NET.aspx" />
    <content type="html">&lt;p&gt;
One of the features we added in CSLA Light was the idea of a "factory" or "observer"
object - kind of like a police sobriety checkpoint - that can be called when any data
portal request comes in from the client. This is a server-side object that can examine
or manipulate the business object or criteria object sent from the client, before
any other server-side processing is allowed.
&lt;/p&gt;
&lt;p&gt;
I liked the idea so much that I decided to put it into the CSLA .NET 3.6 data portal
too. Which turned out to be &lt;em&gt;much&lt;/em&gt; harder than I expected...
&lt;/p&gt;
&lt;p&gt;
Of course I don't want to break compatibility with the current data portal behavior,
so it must continue unchanged.
&lt;/p&gt;
&lt;p&gt;
But if you put the ObjectFactory attribute on your business class, that should redirect
the data portal to create an instance of the factory object you specify, and to route
all data portal calls to methods on &lt;em&gt;that&lt;/em&gt; object instead of calling DataPortal_XYZ
as normal.
&lt;/p&gt;
&lt;p&gt;
For example:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
[ObjectFactory("Factories.MyFactory,Factories")]&lt;br&gt;
[Serializable]&lt;br&gt;
public class CustomerEdit : BusinessBase&amp;lt;CustomerEdit&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This tells the data portal to &lt;em&gt;not&lt;/em&gt; call any DataPortal_XYZ methods, but instead
to create an instance of a MyFactory object and to call methods named Create(), Fetch(),
Update() and Delete() on that object instead.
&lt;/p&gt;
&lt;p&gt;
This is extensible in numerous ways. You can specify the names of the four methods.
You can provide a "factory loader" so that string parameter passed to ObjectFactory
can be interpreted differently - how ever you'd like. The &lt;em&gt;default&lt;/em&gt; factory
loader treats that string like an assembly qualified type name, because I think that's
what most people will want.
&lt;/p&gt;
&lt;p&gt;
So you have to create MyFactory:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
namespace Factories&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; public class MyFactory&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [RunLocal]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public object Create()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // create object here&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return obj;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public object Fetch(SingleCriteria&amp;lt;CustomerEdit, int&amp;gt; criteria)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // retrieve object here&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return obj;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [Transactional(TransactionTypes.TransactionScope)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public object Update(CustomerEdit obj)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // insert/update/delete object here&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [Transactional(TransactionTypes.TransactionScope)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void Delete(SingleCriteria&amp;lt;CustomerEdit, int&amp;gt; criteria)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // delete data here&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Normal method overloading rules apply to these methods. So you can have multiple Fetch()
methods with different criteria object types and the data portal will call the right
method. This is exactly the same behavior as with DataPortal_Create(), DataPortal_Fetch()
and DataPortal_Delete() today.
&lt;/p&gt;
&lt;p&gt;
Notice that the RunLocal and Transactional attributes can be applied to these methods
just like they would have been applied to the DataPortal_XYZ methods.
&lt;/p&gt;
&lt;p&gt;
RunLocal is interesting though, because it obviously can only work if you deploy your
factory assembly to the client along with the business assembly. In most cases I expect
people won't choose to do that, and so won't be able to use RunLocal.
&lt;/p&gt;
&lt;p&gt;
The default for Transactional is to use Manual transactions. In other words, if you
don't use the attribute it is entirely up to your factory method to handle any transaction
details.
&lt;/p&gt;
&lt;p&gt;
It is &lt;em&gt;very important&lt;/em&gt; to realize that when using this factory model, the data
portal does virtually nothing for you. It doesn't automatically call MarkOld(), MarkNew()
or MarkAsChild(). You assume &lt;em&gt;total responsibility&lt;/em&gt; for creating and initializing
the business object graph, and for setting the state of all objects in the graph.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=f3a055cd-c027-4892-a263-505afbc12661" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>CSLA Light data provider</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/CSLALightDataProvider.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,9eb589a1-fc7f-48a9-92a8-6ca97ff92c13.aspx</id>
    <published>2008-08-13T12:03:32.137-05:00</published>
    <updated>2008-08-13T12:04:11.3834368-05:00</updated>
    <category term="CSLA .NET" label="CSLA .NET" scheme="http://www.lhotka.net/weblog/CategoryView,category,CSLA%2B.NET.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://www.lhotka.net/weblog/CategoryView,category,Silverlight.aspx" />
    <content type="html">&lt;p&gt;
WPF has this cool concept called a data provider control. CSLA .NET includes a custom
data provider control that enables nearly codeless forms (if you don't count XAML
as code), by supporting the following functions purely through XAML:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Create/Fetch an object 
&lt;li&gt;
Save an object 
&lt;li&gt;
Cancel changes to an object 
&lt;li&gt;
Add a new item to a list (if the object is a collection) 
&lt;li&gt;
Remove an item from a list (if the object is a collection)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Silverlight doesn't have a data provider concept, nor does it have &lt;em&gt;commanding&lt;/em&gt;.
Which means that you need to write code behind the form for all of those actions.
&lt;/p&gt;
&lt;p&gt;
So in CSLA Light we're investigating the possibility of some sort of data provider
control to fill in this gap. The idea is that you'd be able to declare a CslaDataProvider
as a resource on your form and use it as a data source, and as a handler for the save/cancel/add/remove
operations.
&lt;/p&gt;
&lt;p&gt;
This also means we need a way, through XAML, to route things like a button's Click
event to methods on CslaDataProvider (because there's no commanding in Silverlight).
&lt;/p&gt;
&lt;p&gt;
At a prototype level what we've got is something like this. The CslaDataProvider goes
in the Resources section just like it would in WPF:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;UserControl.Resources&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;csla:CslaDataProvider x:Key="MyData"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
ManageObjectLifetime="True" /&amp;gt;&lt;br&gt;
&amp;lt;/UserControl.Resources&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Some WPF concepts don't make sense. For example, IsAsynchronous is useless because
in Silverlight it &lt;em&gt;will be asynchronous&lt;/em&gt;. Others, like IsInitialLoadEnabled
might make sense, we're not entirely sure yet.
&lt;/p&gt;
&lt;p&gt;
Your page XAML then uses this as a data source. But where WPF does some magic behind
the scenes for data providers, Silverlight doesn't know about data providers. So you
have to deal with this yourself when setting the DataContext:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource MyData},
Path=Data}"&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The DataContext is set to use the Data property of the data provider, because that's
where the actual business object is found. In WPF this indirection is hidden automatically,
but in Silverlight you have to do it yourself.
&lt;/p&gt;
&lt;p&gt;
In the Form_Loaded() method in code behind you call your business object's factory
method. But rather than handling the async callback yourself, you allow the data provider
to handle it:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
private void Form_Loaded(...)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; var dp = (CslaDataProvider)this.Resources["MyData"];&lt;br&gt;
&amp;nbsp; CustomerEdit.GetCustomer(123, dp.FetchCompleted);&lt;br&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I hope to eliminate even this bit of code behind (at least for parameterless create/fetch
scenarios), but the current prototype does require it. The CslaDataProvider exposes
a set of async handlers for create and fetch operations.
&lt;/p&gt;
&lt;p&gt;
When the async request completes, the CslaDataProvider object's Data property changes
to reflect the new business object. That causes a PropertyChanged event, which in
turn causes data binding to refresh the UI so the user sees the data.
&lt;/p&gt;
&lt;p&gt;
That gets us pretty close to the WPF data provider capability of creating or retrieving
an object. But the Csla.Wpf.CslaDataProvider goes further, and so the plan is for
the Csla.Silverlight.CslaDataProvider to also go further.
&lt;/p&gt;
&lt;p&gt;
The data provider object has methods like Save() and Cancel() that can be called to
save the object or cancel changes. The trick then, is how to get UI elements, like
a button, to call those methods when Silverlight has no commanding or relative binding.
&lt;/p&gt;
&lt;p&gt;
At the moment we're addressing this with an InvokeMethod object that exposes some
attached properties. So you can create a Button like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;Button csla:InvokeMethod.Resource="{StaticResource MyData}"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.MethodName="Save"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; csla:InvokeMethod.TriggerEvent="Click"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Content="Save"
/&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This tells the InvokeMethod object to listen for a Click event from the Button. When
it gets a Click event, it invokes the Save() method on the MyData resource. Any RoutedEventHandler
or EventHander event can be handled, which should cover nearly all events from any
type of UI control. The Button control's Click event, for example, is a RoutedEventHandler,
as are most Silverlight control events.
&lt;/p&gt;
&lt;p&gt;
(this is only possible btw, thanks to the relaxed delegate support in the current
versions of C# and VB)
&lt;/p&gt;
&lt;p&gt;
The same technique will work to call Cancel(), and presumably AddNewItem() and RemoveItem()
at some point (though with RemoveItem() we'll also need a way to pass in a parameter
value to specify the item to be removed).
&lt;/p&gt;
&lt;p&gt;
The result is that we're pretty close, at least in concept, to the WPF data provider
model, and we avoid the need to write code behind the form for common events like
save, cancel, add new and remove.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=9eb589a1-fc7f-48a9-92a8-6ca97ff92c13" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>Using CSLA Light Part 4</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/UsingCSLALightPart4.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,3be2e589-6106-49b7-a34d-96413815e2a2.aspx</id>
    <published>2008-08-12T10:05:57.956-05:00</published>
    <updated>2008-08-12T10:07:31.3307568-05:00</updated>
    <category term="CSLA .NET" label="CSLA .NET" scheme="http://www.lhotka.net/weblog/CategoryView,category,CSLA%2B.NET.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://www.lhotka.net/weblog/CategoryView,category,Silverlight.aspx" />
    <content type="html">&lt;p&gt;
In &lt;a href="http://www.lhotka.net/weblog/ct.ashx?id=74fc453c-5522-4a7f-bc0f-19258cdd932e&amp;amp;url=http%3a%2f%2fwww.lhotka.net%2fweblog%2fUsingCSLALightPart1.aspx"&gt;Part
1&lt;/a&gt; of this series I discussed the overall architecture and structure of a CSLA
Light application. In &lt;a href="http://www.lhotka.net/weblog/ct.ashx?id=74fc453c-5522-4a7f-bc0f-19258cdd932e&amp;amp;url=http%3a%2f%2fwww.lhotka.net%2fweblog%2fUsingCSLALightPart2.aspx"&gt;Part
2&lt;/a&gt; I walked through the creation of a simple &lt;a href="http://www.lhotka.net/weblog/ct.ashx?id=74fc453c-5522-4a7f-bc0f-19258cdd932e&amp;amp;url=http%3a%2f%2fwww.lhotka.net%2fArticle.aspx%3farea%3d4%26id%3d4484d01a-faa9-4220-a5c9-065e7b43b0af"&gt;editable
root&lt;/a&gt; business object that supports both the 3-tier and 4-tier mobile object models.
In &lt;a href="http://www.lhotka.net/weblog/UsingCSLALightPart3.aspx"&gt;Part 3&lt;/a&gt; I discussed
the creation of the Silverlight UI.
&lt;/p&gt;
&lt;p&gt;
In this post I will discuss the configuration of the web/app server and the data portal.
&lt;/p&gt;
&lt;p&gt;
All Silverlight applications require a web server, because the Silverlight runtime
is hosted in a web page, and the user has to get the web page from a web server (I'm
sure there are exceptions to this rule - but in practicality, nearly all Silverlight
apps will be downloaded from a web server).
&lt;/p&gt;
&lt;p&gt;
When using CSLA Light in a 3- or 4-tier client/server model, the CSLA Light client
application will communicate with a .NET application server. That application server
might be the same server from which the Silverlight app was downloaded, or a different
server. It might be hosted in ASP.NET or WAS or a custom Windows Service.
&lt;/p&gt;
&lt;p&gt;
The CSLA Light data portal uses WCF as its network transport, and so the only requirement
is that the server be reachable from the client using the Silverlight WCF implementation.
&lt;/p&gt;
&lt;p&gt;
CSLA .NET 3.6 includes a special data portal host designed to work with a CSLA Light
client. Remember that the CSLA Light data portal is not only going across the network,
but it is communicating between the .NET and Silverlight platforms. So while this
data portal is functionally similar to the .NET data portal, it has to do some extra
work thanks to the cross-platform nature of the scenario.
&lt;/p&gt;
&lt;h4&gt;Configuring the Server
&lt;/h4&gt;
&lt;p&gt;
The simplest server configuration is to put the data portal host in the same virtual
root as the Silverlight application itself, and that's what I've done in this example.
&lt;/p&gt;
&lt;p&gt;
When the Silverlight application was created, Visual Studio automatically created
a host web application project. What I've done is added a WcfPortal.svc file, some
web.config entries and a reference to Csla.dll to this project:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/UsingCSLALightPart4_8DC1/image_2.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=210 alt=image src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/UsingCSLALightPart4_8DC1/image_thumb.png" width=330 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The WcfPortal.svc file is a typical WCF service file:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;% @ServiceHost Service="Csla.Server.Hosts.Silverlight.WcfPortal" %&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
It references the WcfPortal class that contains the data portal host designed to work
with CSLA Light. Notice that it comes from the Csla.Server.Hosts.Silverlight namespace.
&lt;/p&gt;
&lt;p&gt;
The web project references Csla.dll, and of course also references Library.dll &lt;em&gt;from
the Library.Server project&lt;/em&gt;. Remember that Library.Server is a .NET Class Library
project containing all the business classes, while Library.Client is a Silverlight
Class Library project. Since the web server is running .NET, it needs to reference
the .NET assembly.
&lt;/p&gt;
&lt;p&gt;
Finally, the web.config file contains the WCF configuration necessary for the WcfPortal
to be available to clients:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;behavior name="WcfPortalBehavior"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;serviceMetadata httpGetEnabled="true"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;serviceDebug includeExceptionDetailInFaults="true"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behavior&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/serviceBehaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/behaviors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;services&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;service behaviorConfiguration="WcfPortalBehavior" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
name="Csla.Server.Hosts.Silverlight.WcfPortal"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint address="" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="basicHttpBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="Csla.Server.Hosts.Silverlight.IWcfPortal"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;identity&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;dns value="localhost"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/identity&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/endpoint&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/service&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/services&amp;gt;&lt;br&gt;
&amp;lt;/system.serviceModel&amp;gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
This is pretty standard WCF configuration, defining an endpoint for the IWcfPortal
interface from Csla.Server.Hosts.Silverlight. Notice that the name of the service
(Csla.Server.Hosts.Silverlight.WcfPortal) matches the name of the service specified
in the svc file.
&lt;/p&gt;
&lt;p&gt;
At this point the app server is configured and ready to go.
&lt;/p&gt;
&lt;h4&gt;Configuring the Client
&lt;/h4&gt;
&lt;p&gt;
In Silverlight, WCF gets its configuration from a file called ServiceReferences.ClientConfig.
In Beta 2 I've found that WCF doesn't consistently read this file, but it does work
in the sample app I'm discussing here, and I assume Microsoft will fix whatever is
causing the file to sometimes be ignored.
&lt;/p&gt;
&lt;p&gt;
The config file looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;configuration&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;system.serviceModel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;basicHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;binding name="BasicHttpBinding_IWcfPortal" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
maxBufferSize="65536"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
maxReceivedMessageSize="65536" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
receiveTimeout="10" sendTimeout="10"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/binding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/basicHttpBinding&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/bindings&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;client&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;endpoint&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
address="&lt;a href="http://localhost:1406/SimpleAppWeb/WcfPortal.svc"&gt;http://localhost:1406/SimpleAppWeb/WcfPortal.svc&lt;/a&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
binding="basicHttpBinding" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bindingConfiguration="BasicHttpBinding_IWcfPortal"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contract="Csla.WcfPortal.IWcfPortal" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
name="BasicHttpBinding_IWcfPortal" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/client&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/system.serviceModel&amp;gt;&lt;br&gt;
&amp;lt;/configuration&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Again, pretty standard-looking WCF configuration like you'd probably find in an app.config
file. It sets up a client endpoint for IWcfPortal, and provides the URL address to
the server.
&lt;/p&gt;
&lt;p&gt;
You can optionally override the configuration in your code by setting two static properties:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Csla.DataPortalClient.WcfProxy.DefaultUrl = "http://localhost/root/WcfPortal.svc"&lt;br&gt;
Csla.DataPortalClient.WcfProxy.DefaultBinding = myBinding
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I've been using the config file approach for the most part, but there are certainly
scenarios where you might need to switch to different app server addresses in a more
dynamic manner.
&lt;/p&gt;
&lt;p&gt;
Finally, your application can specify whether the data portal should run in local
or remote mode by setting a property:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Csla.DataPortal.ProxyTypeName = "Csla.DataPortalClient.WcfProxy, Csla"
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
By default the data portal is configured for remote mode, using WCF, and so the sample
app doesn't do any configuration of the ProxyTypeName. But if you did want to run
the data portal in local mode, you'd set the ProxyTypeName to "Local": &lt;blockquote&gt; 
&lt;p&gt;
Csla.DataPortal.ProxyTypeName = "Local"
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Then the DataPortal_XYZ methods would run on the Silverlight client and the data portal
won't interact with an app server at all. That is particularly useful if you want
to directly call remote services from your Silverlight client, and the primary scenario
in our design is to support the use of .NET Data Services (code name Astoria) - but
that is a topic for another sample app. 
&lt;p&gt;
In &lt;em&gt;this&lt;/em&gt; sample app the only configuration required is in ServiceReferences.ClientConfig.
The data portal defaults to the correct settings to use the values in this file to
communicate with a CSLA .NET application server. 
&lt;p&gt;
As you can see, configuring the application server and client to use the CSLA Light
data portal is not difficult. The data portal relies on standard WCF configuration
on both ends of the network connection, allowing you to exploit the power and flexibility
of WCF to access the mobile object capabilities provided by the data portal.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=3be2e589-6106-49b7-a34d-96413815e2a2" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>Check out CodeBreeze</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/CheckOutCodeBreeze.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,4740097a-c28c-4273-8bf6-51819528adef.aspx</id>
    <published>2008-08-11T16:33:03.9230912-05:00</published>
    <updated>2008-08-11T16:33:03.9230912-05:00</updated>
    <content type="html">&lt;p&gt;
There are many code generation tools and templates available for CSLA .NET. You can
find a list here
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.lhotka.net/cslanet/codegen.aspx" href="http://www.lhotka.net/cslanet/codegen.aspx"&gt;http://www.lhotka.net/cslanet/codegen.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Over time I expect to blog about several of the options, usually as they release new
versions or updated templates.
&lt;/p&gt;
&lt;p&gt;
One of the more robust options is &lt;a href="http://www.steelbluesolutions.com/Summary/CodeBreeze/Default.aspx"&gt;CodeBreeze&lt;/a&gt;,
from Miguel Castro. Miguel just released a new version of his product, which includes
completely refreshed CSLA .NET code-gen templates.
&lt;/p&gt;
&lt;p&gt;
Miguel is also the author of the CSLA .NET training class from Dunn training, so he
knows CSLA inside and out. He's put up a forum to support CodeBreeze at &lt;a href="http://community.steelbluesolutions.com"&gt;http://community.steelbluesolutions.com&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=4740097a-c28c-4273-8bf6-51819528adef" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
  <entry>
    <title>Using CSLA Light Part 3</title>
    <link rel="alternate" type="text/html" href="http://www.lhotka.net/weblog/UsingCSLALightPart3.aspx" />
    <id>http://www.lhotka.net/weblog/PermaLink,guid,74fc453c-5522-4a7f-bc0f-19258cdd932e.aspx</id>
    <published>2008-08-11T12:50:41.447-05:00</published>
    <updated>2008-08-11T12:51:28.6454208-05:00</updated>
    <category term="CSLA .NET" label="CSLA .NET" scheme="http://www.lhotka.net/weblog/CategoryView,category,CSLA%2B.NET.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://www.lhotka.net/weblog/CategoryView,category,Silverlight.aspx" />
    <content type="html">&lt;p&gt;
In &lt;a href="http://www.lhotka.net/weblog/UsingCSLALightPart1.aspx"&gt;Part 1&lt;/a&gt; of this
series I discussed the overall architecture and structure of a CSLA Light application.
In &lt;a href="http://www.lhotka.net/weblog/UsingCSLALightPart2.aspx"&gt;Part 2&lt;/a&gt; I walked
through the creation of a simple &lt;a href="http://www.lhotka.net/Article.aspx?area=4&amp;amp;id=4484d01a-faa9-4220-a5c9-065e7b43b0af"&gt;editable
root&lt;/a&gt; business object that supports both the 3-tier and 4-tier mobile object models.
&lt;/p&gt;
&lt;p&gt;
In this post I want to cover the Silverlight UI. Following the theme of this walkthrough,
the UI will be very simple so I can illustrate the basic requirements and concepts.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/UsingCSLALightPart3_127D0/image_4.png"&gt;&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=240 alt=image src="http://www.lhotka.net/weblog/content/binary/WindowsLiveWriter/UsingCSLALightPart3_127D0/image_thumb_1.png" width=358 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
At this point in time we're working on UI support for authorization, and I'll discuss
it when we have something to show.
&lt;/p&gt;
&lt;h4&gt;UI XAML
&lt;/h4&gt;
&lt;p&gt;
The XAML for the UI is not complex, but does have some interesting differences from
typical WPF XAML:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&amp;lt;UserControl x:Class="SimpleApp.Page"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns="&lt;a href='http://schemas.microsoft.com/winfx/2006/xaml/presentation"' temp_href='http://schemas.microsoft.com/winfx/2006/xaml/presentation"'&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/a&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:x=&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml"&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/a&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:csla="clr-namespace:Csla.Wpf;assembly=Csla" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Width="800" Height="600" Loaded="UserControl_Loaded"&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;Grid x:Name="LayoutRoot" Background="Beige"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Margin="5,5,5,5"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal" Margin="5,5,5,5"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock Width="100" Text="Id" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBox Width="150" Text="{Binding
Id, Mode=TwoWay}" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;csla:PropertyStatus Property="Name"
Source="{Binding}" /&amp;gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal" Margin="5,5,5,5"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock Width="100" Text="Name" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBox Width="150" Text="{Binding
Name, Mode=TwoWay}" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal" Margin="5,5,5,5"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock Width="100" Text="Status"
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock Width="150" Text="{Binding
Status}" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;StackPanel Orientation="Horizontal" Margin="5,5,5,5"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Button Width="50" HorizontalAlignment="Left"
Margin="5,5,5,5"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Click="Button_Click"
Content="Save" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Button Width="50" HorizontalAlignment="Left"
Margin="5,5,5,5"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Click="Delete_Click"
Content="Delete" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/StackPanel&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/Grid&amp;gt;&lt;br&gt;
&amp;lt;/UserControl&amp;gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The primary difference is that the Mode=TwoWay expression is &lt;em&gt;required&lt;/em&gt; to
get two-way data binding. In WPF the default is two-way, and in Silverlight it appears
to be one-way.
&lt;/p&gt;
&lt;p&gt;
Also, in WPF I would have created a Style for the StackPanel controls to pull the
Margin property into a Resources block. While I was able to get a Style working for
a TextBlock or TextBox, it would not work for StackPanel. Could be something I did,
or a bug or missing feature in Silverlight... Certainly the XAML to do that from WPF
doesn't work in Silverlight.
&lt;/p&gt;
&lt;p&gt;
In WPF I probably would have used a CslaDataProvider control as my binding source.
The WPF data provider control model is really nice, and I use it all the time. Unfortunately
Silverlight doesn't have a data provider concept, and so obviously that's not here.
&lt;/p&gt;
&lt;p&gt;
Notice the PropertyStatus control from CSLA .NET. It is in the Csla.Wpf namespace,
but will be moving to Csla.Silverlight. PropertyStatus handles both validation and
authorization on a per-control basis, and is responsible for the error icon and tooltip
in the UI. It also shows warning and information severity broken rules, and so is
more comprehensive than the ErrorProvider in Windows Forms or the error support in
WPF.
&lt;/p&gt;
&lt;h4&gt;Creating or Retrieving the Object
&lt;/h4&gt;
&lt;p&gt;
When this form is loaded, the business object is either created or retrieved:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Private Sub UserControl_Loaded( _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)&lt;br&gt;
&lt;br&gt;
&amp;nbsp; 'Library.CustomerEdit.BeginGetCustomer(123, AddressOf BindCustomer)&lt;br&gt;
&amp;nbsp; Library.CustomerEdit.BeginNewCustomer( _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Csla.DataPortal.ProxyModes.Auto, AddressOf BindCustomer)&lt;br&gt;
&lt;br&gt;
End Sub 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Remember from &lt;a href="http://www.lhotka.net/weblog/UsingCSLALightPart2.aspx"&gt;Part
2&lt;/a&gt; that the BeginNewCustomer() factory creates a new object, while the BeginGetCustomer()
retrieves an existing object (or at least mocks that behavior). I've commented out
the BeginGetCustomer() call, so the code shown here is creating a new object.
&lt;/p&gt;
&lt;p&gt;
Don't mind the ProxyModes.Auto parameter to BeginNewCustomer(). This is something
I'm working on to allow a factory method to force the data portal to run in local
mode, and will probably be the topic of a future blog post. The Auto setting indicates
that the data portal should use its default behavior.
&lt;/p&gt;
&lt;p&gt;
In either case, the factory methods accept a delegate reference that points to a callback
handler. These factories are asynchronous, so the code you see here merely &lt;em&gt;starts
the process&lt;/em&gt;. You need to implement a callback handler that is invoked when the
asynchronous operation is complete. That looks like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Private Sub BindCustomer( _&lt;br&gt;
&amp;nbsp; ByVal sender As Object, ByVal e As Csla.DataPortalResult(Of Library.CustomerEdit)) 
&lt;p&gt;
&amp;nbsp; Me.LayoutRoot.DataContext = e.Object 
&lt;p&gt;
End Sub 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
In C# you could shorten this code by using an anonymous delegate or multi-line lambda
instead of creating a totally separate method to handle the callback. Having tried
all three approaches, I must say that I still prefer the approach you see here, even
in C#, because I find it easier to read the code. Obviously you may find one of the
other approaches easier to read - personal preference at work.
&lt;/p&gt;
&lt;p&gt;
The important thing to remember is that BindCustomer() is called by the data portal
when the asynchronous operation is complete. In other words, while the object was
being created/retrieved on the server, the user was still able to interact with the
UI and the browser. Then, when the server is done with its work, this BindCustomer()
method is invoked (much like an event being raised) so you can process the result.
&lt;/p&gt;
&lt;p&gt;
The DataPortalResult parameter has a couple important properties: Object and Error.
The Object property contains a reference to the business object that was created/retrieved.
The Error property contains a reference to any exception that may have occurred during
the asynchronous operation.
&lt;/p&gt;
&lt;p&gt;
Please note that the BindCustomer() callback occurs &lt;em&gt;on the UI thread&lt;/em&gt;. Behind
the scenes the data portal is using WCF, and WCF callbacks in Silverlight always occur
on the UI thread. This is really nice, because it means that the developer doesn't
have to worry about marshalling the call to the UI thread like they would in WPF.
&lt;/p&gt;
&lt;p&gt;
In the end, all this method does is to take the business object that was just returned
from the data portal, and uses it to set the DataContext for the top-level Grid control
in the UI. That causes all the detail controls contained in that Grid control to bind
to the object according to the binding expressions in the XAML.
&lt;/p&gt;
&lt;h4&gt;Saving the Object
&lt;/h4&gt;
&lt;p&gt;
When the Save button is clicked, the object is either inserted or updated into the
database. As with CSLA .NET objects, CSLA Light objects keep track of whether they
are new or old, and so the UI developer doesn't need to worry about whether the save
is an insert or update - that's automatically handled by the data portal.
&lt;/p&gt;
&lt;p&gt;
Also, like in CSLA .NET, the object keeps track of whether it has been changed. So
clicking the Save button when the object has not been changed will result in nothing
happening - the object automatically detects that it hasn't been changed and doesn't
really invoke the server to do a meaningless update operation.
&lt;/p&gt;
&lt;p&gt;
In WPF, with CSLA .NET, the Save button probably would have no code, but would work
using the concept of &lt;em&gt;commanding&lt;/em&gt; and the CslaDataProvider. Unfortunately commanding
doesn't exist in Silverlight, nor do data providers. So in Silverlight the Save button
behavior is implemented in old-fashioned code-behind event handlers.
&lt;/p&gt;
&lt;p&gt;
The following code handles the Save button's Click event:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Private Sub Button_Click( _&lt;br&gt;
&amp;nbsp; ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) 
&lt;p&gt;
&amp;nbsp; Dim cust = CType(Me.LayoutRoot.DataContext, Library.CustomerEdit)&lt;br&gt;
&amp;nbsp; cust.BeginSave(AddressOf BindSaveResult) 
&lt;p&gt;
End Sub 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
First, the business object is retrieved from the form's DataContext, and the object
is cast into the right type.
&lt;/p&gt;
&lt;p&gt;
Then the BeginSave() method is called to start the save process. Again, all server
communication must be asynchronous in Silverlight and so the data portal is asynchronous.
This means the save operation is asynchronous as well, and so a callback delegate
is passed as a parameter.
&lt;/p&gt;
&lt;p&gt;
Remember that the Click event handler &lt;em&gt;exits immediately&lt;/em&gt; and the user can
interact with the UI and browser while the save operation is occurring on the server.
The UI will probably need to take steps to disable important buttons and controls
to prevent the user from interacting with the object (or flooding the server with
repeated save requests or something) while the asynchronous operation is executing.
&lt;/p&gt;
&lt;p&gt;
That BindSaveResult() method will be invoked when the asynchronous operation is complete:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Private Sub BindSaveResult( _&lt;br&gt;
&amp;nbsp; ByVal sender As Object, ByVal e As Csla.Core.SavedEventArgs)&lt;br&gt;
&lt;br&gt;
&amp;nbsp; Me.LayoutRoot.DataContext = e.NewObject&lt;br&gt;
&lt;br&gt;
End Sub 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Just like in CSLA .NET, the data portal in CSLA Light returns &lt;em&gt;a new object&lt;/em&gt; as
a result of the save operation. This means that the UI &lt;em&gt;must be rebound to use
the new object&lt;/em&gt; when the operation is complete.
&lt;/p&gt;
&lt;h4&gt;Deleting the Object
&lt;/h4&gt;
&lt;p&gt;
When the Delete button is clicked, the object is deleted from the database. CSLA Light
supports both immediate and deferred deletion. In this sample app I'm illustrating
deferred deletion, where the object has been retrieved, it is marked for deletion
and then saved. Here's the Click handler behind the button:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Private Sub Delete_Click( _&lt;br&gt;
&amp;nbsp; ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)&lt;br&gt;
&lt;br&gt;
&amp;nbsp; Dim cust = CType(Me.LayoutRoot.DataContext, Library.CustomerEdit)&lt;br&gt;
&amp;nbsp; cust.Delete()&lt;br&gt;
&amp;nbsp; cust.BeginSave(AddressOf BindSaveResult)&lt;br&gt;
&lt;br&gt;
End Sub 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The code is much like that for the Save button, but in this case the Delete() method
is called on the object before it is saved. This marks the object to be deleted, so
the data portal automatically routes the call to DataPortal_DeleteSelf() so that occurs.
&lt;/p&gt;
&lt;p&gt;
The resulting object (which is now considered a "new" object) is bound to the UI in
the same BindSaveResult() method I discussed earlier.
&lt;/p&gt;
&lt;h4&gt;Summary
&lt;/h4&gt;
&lt;p&gt;
In this post I have walked through the basic creation of a Silverlight UI that binds
to a business object. The object is created or retrieved through the data portal,
and then is inserted, updated or deleted through the data portal.
&lt;/p&gt;
&lt;p&gt;
It is probably worth noting that CSLA .NET 3.6 will also include the same asynchronous
data portal concepts shown here, and so the same basic code can be written behind
a WPF, Windows Forms or even Web Forms UI.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.lhotka.net/weblog/aggbug.ashx?id=74fc453c-5522-4a7f-bc0f-19258cdd932e" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;div style="border-top: 1px dotted;padding-top: 8px;padding-bottom: 5px;margin-top: 10px;margin-bottom: 0px;font-family: Verdana;font-weight: normal;line-height: 100%;text-align: left;"&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag Start --&gt;
&lt;script type="text/javascript" src="http://ads.aspalliance.com/displayad.aspx?t=3&amp;m=90&amp;guid=4"&gt;&lt;/script&gt;
&lt;!-- Text Ads - Product Spotlight Ad Tag End --&gt;
&lt;br clear="all"&gt;
&lt;/div&gt;
  </content>
  </entry>
</feed>