Rockford Lhotka's Blog

Home | Lhotka.net | CSLA .NET

 Friday, April 27, 2007

The third pre-beta test release of CSLA .NET 3.0 is now available for download.

This release doesn't include any major changes from the previous release, but does include a set of bug fixes and stabilization.

This release does include an updated ProjectTracker application, which now includes:

  • PTWpf - the almost completed WPF UI for ProjectTracker
  • PTWorkflow - a simple workflow that makes use of CSLA-style objects in the activities
  • WcfPortal - a data portal host for the WCF data portal channel
  • PTWcfService - a WCF service interface, much like the older web service interface
  • PTWcfServiceClient - a Windows Forms client app for PTWcfService

Plus, of course, all the pre-existing Windows, ASP.NET and web service interfaces and data portal hosts.

This release is only available in C# at the moment. The WCF data portal channel for VB is complete, and is available directly from the svn repository. I'll port the remainder of the changes to VB once I'm more confident that they are stable (which should be in the relatively near future).

Friday, April 27, 2007 8:48:44 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, April 26, 2007

I'm confused...

Reading through the WPF docs it is pretty clear that, when building a page-based WPF app, the WPF container (which looks kind of like a stripped down IE) doesn't keep old page instances in memory. So when you click the back button, previous pages are reloaded.

I found this to be the case with one of my pages, where not only did the page reload, but all the data binding was broken when that occurred. So I had to set KeepAlive to true for that page to make it work. That made some sense to me (though I still don't understand why the data binding within the page was all messed up...)

But now I'm finding that other pages are not reloaded. In fact, they are cached in memory, so when I use the Back button to get to them they are showing outdated data.

What a serious pain. I'm sure there are some rules at work behind the scenes here - but I wish the WPF docs were more clear as to what those rules actually were... It appears that the rules are designed to frustrate me: when I want a page to stay in memory it gets reloaded, but when I want a page to reload it stays in memory. Perhaps that's the rule? :)

 

So the problem I'm trying to resolve right now is this:

I have a page showing Project 123. I then navigate to another page, where I'm able to alter some of the data for Project 123. I then use the Back button to get back to the Project 123 page, but it still shows the old data - making it very clear that the page was not reloaded, but rather was cached.

Worse, there doesn't appear to be any nice event raised in a Page object to indicate that it was just navigated to, so I have no way of forcing a refresh of the data. That'd be too easy I guess...

Explicitly setting KeepAlive to false has no affect. And I didn't think it would - false is supposed to be the default value.

And I have double-checked to make sure my code doesn't keep any reference to any pages. But I don't: I just create a page object in a method using a local variable and navigate to it using the WPF navigation service.

 

To be very clear, I actually have a single main page that has a Frame control. My content pages are displayed in this Frame, and my navigation is like this:

   _mainFrame.NavigationService.Navigate(page);

Which does appear to work in all respects, except that page objects are and aren't cached in memory in ways that defy the docs and any rational logic I can see...

Ideas anyone?

Thursday, April 26, 2007 3:15:23 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
Aaron Erickson, a Magenic consultant, has been working on an interesting project: providing an indexing service for LINQ. You can get full information about i4o from this blog post, and from the official codeplex site.

You might wonder why this matters, given that LINQ uses database indexes to get its data. But that's actually Dlinq, which runs against SQL Server.

LINQ itself runs against objects, arrays, collections, lists and so forth. All of which are just in-memory objects, and obviously aren't indexed at all. LINQ does "table scans" against arrays and lists at all times. Basically LINQ just runs a lot of for-each loops for you. And in the vast majority of cases that is the right answer, because most lists are only a few score or maybe a few hundred items in length, and using for-each is faster than building an index.

However, you might have lists that are big enough, or where you are doing many repeated queries against the same set of properties, where the cost of building an index is lower than the cost of using simple for-each loops. And this is where the ability to index properties of the objects in a list such that LINQ uses the index becomes very useful.

In any case, check out i4o, because it is interesting and very cool stuff!

Thursday, April 26, 2007 8:33:32 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, April 24, 2007

I am building a WPF UI for my ProjectTracker CSLA .NET sample app. On the whole this is going pretty well, and I anticipate being done within the next couple days. I’ve found and fixed a couple bugs in CSLA – one in BusinessListBase that’s been there forever, and one in ValidationPanel that caused a null reference exception. While I fixed that last one, I optimized the code a bit, which does seem to make the control a bit faster.

But one thing I spent a ridiculous amount of time on was the simple process of getting a ComboBox control to bind to one data source to get its list of items, and to the business object property for the key value. Google turned up a number of search results, none of which really addressed this particular scenario – which seems odd to me given how common a scenario it is…

In ProjectTracker, a person (resource) can be assigned to a project. If they are, they are given a role on that project. The Role property is numeric – a key into a name/value list, and a foreign key into the Roles table in the database. In Windows Forms and Web Forms the UI handles translating this numeric value to a human-readable value through ComboBox controls, and obviously WPF can do the same thing. The trick is in figuring out the XAML to make it happen.

Here’s the ComboBox XAML:

            <ComboBox

              ItemsSource="{Binding Source={StaticResource RoleList}}"

              DisplayMemberPath="Value"

              SelectedValuePath="Key"

              SelectedValue="{Binding Path=Role}"

              Width="150" />

 

Let’s break this down.

The ItemsSource property specifies the data source for the data that will populate the display of the control. In my case it is referencing a data provider control defined like this:

  <Page.Resources>

    <csla:CslaDataProvider x:Key="RoleList"

                           ObjectType="{x:Type PTracker:RoleList}"

                           FactoryMethod="GetList"

                           IsAsynchronous="False" />

  </Page.Resources>

 

This data provider control loads a name/value list object called RoleList (that inherits from Csla.NameValueListBase). The child objects in this collection expose properties Key and Value.

You can see how the ComboBox uses the DisplayMemberPath to specify that the Value property from the name/value list should be displayed to the user, and the SelectedValuePath specifies that the Key value from the list should be used to select the current item (the Key value is not displayed to the user).

Then notice that the SelectedValue property is used to bind to the main business object. This binding statement sets a path to a property on the overall DataContext for the ComboBox, which in my case is actually set through code at the Page object level:

      this.DataContext = project;

So all controls on the entire page, by default, bind to a Project object, and this includes the ComboBox.

Remember though, that the Role property on the Project is a numeric index value. And so is the Key value from the name/value list. The ComboBox control connects these two automatically. So when the business object’s Role property changes, the ComboBox automatically changes the displayed/selected item. Conversely, when the user changes the ComboBox selected item, that automatically causes the business object’s Role property to change.

Tuesday, April 24, 2007 7:55:13 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, April 23, 2007

I just spent more time than I care to think about chasing down a silly config error in the Visual Studio codename "Orcas" Beta 1 VPC image.

I wanted to run a pre-existing web site, so I copied it to the VPC, aimed a virtual directory at it in IIS and BOOM! 404 errors.

I figured it was directory permissions, incorrect paths, all sorts of things.

Eventually, in frustration I opened VS and created a new ASP.NET web project at localhost/test. Guess what? VS kindly informed me that ASP.NET wasn't enabled for IIS on this machine, and asked if I'd like to enable it. Of course I said yes - and instantly my pre-existing web site started working.

So if you decided to use the Beta 1 VPC (which is a nice way to go), be aware that ASP.NET is not enabled for IIS, and you'll need to enable it before doing any work with ASP.NET or WCF.

Monday, April 23, 2007 1:43:31 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, April 19, 2007

I was out of touch for a while there, and so I couldn't post about this.

But there's a recent .NET Rocks TV (DNR TV) show where I discuss various data access options for use with CSLA .NET. These include:

  1. Using the approach from my books: the datareader directly in the object
  2. Separating the database connection/command code into a different assembly
  3. Separating the whole data access into a different assembly and using data transfer objects (DTOs) to transfer the data into the business objects
  4. Calling a web service to get the DTOs into the objects (so putting the data access not only in a different assembly, but putting them behind a web service)

Click here to get to the DNR TV show page. I also showed this demo at VS Live in San Franscisco, and will show it again in Orlando in May.

Subsequent to that DNR TV show, I've enhanced the demo to also use LINQ to create the DTOs, and to use VB's late binding capability to make it possible to load the business object with data from the local DTO, the web service DTO and the LINQ DTO without any change to code (remember that web service proxies and LINQ create their own DTO types - so even though they are the same shape, they are actually different types - this is exactly where dynamic language features come in very handy!)

I haven't put the LINQ code online yet, but I will within the next few weeks as I catch up on everything.

Thursday, April 19, 2007 8:44:40 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, April 18, 2007

The next Twin Cities Codecamp is coming up fast: April 28!

The last one was really good, and this one looks to be even better, with more time between sessions and more time to interact with others in the community.

See you there!

Wednesday, April 18, 2007 9:03:49 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, April 11, 2007

We're really not that far away from some major new technology. Visual Studio "Orcas" is slated to ship this fall, and will include .NET 3.5; which includes new compilers. And new compilers always means fun! :)

The VB team is running a series of webcasts to bring everyone up to speed on the language changes and the resulting capabilities.

Wednesday, April 11, 2007 3:09:12 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, April 04, 2007

Two weeks ago today I boarded a flight to San Francisco to speak at a couple conferences. I travel a fair amount, probably 17 trips a year on average. But I never expected how this one would turn out.

This blog post is also an explanation for why I haven’t been responding to emails, forum posts or any other communications, no matter how important, and why I’ll be extremely slow to respond for a few weeks now as well.

I spoke at SD West Thur and Fri. I moved to downtown San Francisco and gave my one day CSLA-related workshop on Sunday.

Monday I attended a Magenic company function in the evening and had a great time – nothing like getting together with a bunch of friendly geeks J

Monday around 11 PM I got sick. I mean sick! Serious stomach pains. I tried various things, but ultimately my wife (via phone) got me to go to the ER.

They put me on an IV for a few hours and got me feeling adequate. The assumption was that this was a very bad intestinal virus (read: stomach flu). If only that were true.

I ended up speaking at only one of my three VS Live sessions, and I really regret that in retrospect. I hate to let people down, but if I’d know what was going on I wouldn’t have stressed my body like that. Professional speakers may make it look relatively easy, and like they are having a fun time (and I think most of us really do enjoy it), but it is really a lot of work to deliver even an hour long session.

Anyway, that night and the next day were worse. So bad I couldn’t see my way to flying, but I still assumed it was the flu, so I rested and drank a lot. Thursday I staggered to SFO and flew home. I knew I must look sick, because I got a lot of odd looks from people in the airport and the plane.

My wife took me home, and I figured I’d be on the mend. She’s so very good at taking care of me and the kids if we’re sick. But by morning I asked her to get me to a doctor.

(pause, writing the above wore me out – I’ll be back later)

To make a long story short, my gall bladder had a gall stone. That stone (probably Monday) had blocked the bile duct. The gall bladder got infected, and the infection had caused swelling, irritating the liver and other nearby organs. I was lucky it didn’t burst due to the infection.

The pressure had caused an old hernia to pop too, just to make things more fun.

The surgeon removed the gall bladder and fixed the hernia Saturday.

I’m still really sick, but at least I’m getting better instead of worse each day, and I feel good about that.

In  a couple weeks things should be well on their way to getting back to normal, so hopefully I’ll start showing up on email and forums more over time. But please be patient. If there’s one thing I learned out of this, it is to keep my priorities straight.

You can also click here for one of my wife’s blog posts recounting some of this from her perspective.

(final note – who’d think you could work up a sweat (twice) just typing in a page of text…)

Wednesday, April 04, 2007 6:40:56 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
On this page....
Search
Archives
Feed your aggregator (RSS 2.0)
October, 2014 (1)
August, 2014 (2)
July, 2014 (3)
June, 2014 (4)
May, 2014 (2)
April, 2014 (6)
March, 2014 (4)
February, 2014 (4)
January, 2014 (2)
December, 2013 (3)
October, 2013 (3)
August, 2013 (5)
July, 2013 (2)
May, 2013 (3)
April, 2013 (2)
March, 2013 (3)
February, 2013 (7)
January, 2013 (4)
December, 2012 (3)
November, 2012 (3)
October, 2012 (7)
September, 2012 (1)
August, 2012 (4)
July, 2012 (3)
June, 2012 (5)
May, 2012 (4)
April, 2012 (6)
March, 2012 (10)
February, 2012 (2)
January, 2012 (2)
December, 2011 (4)
November, 2011 (6)
October, 2011 (14)
September, 2011 (5)
August, 2011 (3)
June, 2011 (2)
May, 2011 (1)
April, 2011 (3)
March, 2011 (6)
February, 2011 (3)
January, 2011 (6)
December, 2010 (3)
November, 2010 (8)
October, 2010 (6)
September, 2010 (6)
August, 2010 (7)
July, 2010 (8)
June, 2010 (6)
May, 2010 (8)
April, 2010 (13)
March, 2010 (7)
February, 2010 (5)
January, 2010 (9)
December, 2009 (6)
November, 2009 (8)
October, 2009 (11)
September, 2009 (5)
August, 2009 (5)
July, 2009 (10)
June, 2009 (5)
May, 2009 (7)
April, 2009 (7)
March, 2009 (11)
February, 2009 (6)
January, 2009 (9)
December, 2008 (5)
November, 2008 (4)
October, 2008 (7)
September, 2008 (8)
August, 2008 (11)
July, 2008 (11)
June, 2008 (10)
May, 2008 (6)
April, 2008 (8)
March, 2008 (9)
February, 2008 (6)
January, 2008 (6)
December, 2007 (6)
November, 2007 (9)
October, 2007 (7)
September, 2007 (5)
August, 2007 (8)
July, 2007 (6)
June, 2007 (8)
May, 2007 (7)
April, 2007 (9)
March, 2007 (8)
February, 2007 (5)
January, 2007 (9)
December, 2006 (4)
November, 2006 (3)
October, 2006 (4)
September, 2006 (9)
August, 2006 (4)
July, 2006 (9)
June, 2006 (4)
May, 2006 (10)
April, 2006 (4)
March, 2006 (11)
February, 2006 (3)
January, 2006 (13)
December, 2005 (6)
November, 2005 (7)
October, 2005 (4)
September, 2005 (9)
August, 2005 (6)
July, 2005 (7)
June, 2005 (5)
May, 2005 (4)
April, 2005 (7)
March, 2005 (16)
February, 2005 (17)
January, 2005 (17)
December, 2004 (13)
November, 2004 (7)
October, 2004 (14)
September, 2004 (11)
August, 2004 (7)
July, 2004 (3)
June, 2004 (6)
May, 2004 (3)
April, 2004 (2)
March, 2004 (1)
February, 2004 (5)
Categories
About

Powered by: newtelligence dasBlog 2.0.7226.0

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014, Marimer LLC

Send mail to the author(s) E-mail



Sign In