Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

MBursill

@MBursill
About
Posts
32
Topics
18
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Mapping a foreign key participating in multiple relationships
    M MBursill

    I have a large database with a subset of five tables described here: http://www.senselessdestruction.com/AssociationProblem.jpg[^] Using the Entity Framework, when creating an entity model based on those tables I get the error: Foreign key constraint 'FK_UserContractCompanies_TimesheetContractEntries' has been omitted from the storage model. Column 'CompanyId' of table 'SMSModel.Store.UserContractCompanies' is a foreign key participating in multiple relationships. A one-to-one Entity Model will not validate since data inconsistency is possible. The intended business logic is to have a subset of users as contract users. A contract user arrives at the workplace, can sign in (an entry is made in the TimesheetEntries table), work for X hours and then sign out. For any user that is a contract user, the TimesheetContractEntries table exists to record their times broken into two records. The first record would be start and end times showing the first 8.5 hours of work, without a related ContractCompanyId, and the second record would be the remaining time with a related ContractCompanyId. I'm using VS 2010 Beta 2, and have tried including foreign key columns in the model. Is the schema of my database flawed or is there anyway to overcome this limitation in the EF? -Mike.

    Database database visual-studio com business beta-testing

  • Filtering Sublist
    M MBursill

    That works, however, I was hoping for a way that didn't return an anonymous type. I wanted to keep the original object containment. The now filtered list of B's still kept inside the respective A's. Starting to think LINQ might not be able to do that. It's a puzzler. :confused: -Mike.

    LINQ csharp linq question

  • Filtering Sublist
    M MBursill

    Thanks for the reply. This is close to what I want, but not exactly. The filtering is taking place on A, but not also B. Perhaps an example would help: Lets say List A was called AlphabetList, and had the letters A through Z, each as an object (an item to the list). Now lets say List B was called NumbersList and each instance contained five numbers. For every AlphabetList there is a NumbersList. The sets might look like this: A (1,2,3,4,5) B (6,7,8,9,10) C (11,12,13,14,15) ... if my independent NumbersList contained (7, 14), I'm looking for a LINQ statement which could filter the AlphabetList to contain only the objects marked B and C, and within those, filter the NumbersList items to only contain the objects with the numbers 7 and 14. Thanks. -Mike.

    LINQ csharp linq question

  • Filtering Sublist
    M MBursill

    You have a list of items (Item type A). For each item in that list, you have a sub-list of items (Item type B). You have another independent list of type B. You wish to filter the first list to only contain the items (and sub-items) in your independent list of type B's. You're using C# and LINQ. How the heck do you do it? -Mike.

    LINQ csharp linq question

  • Binding one DP to another across controls
    M MBursill

    Thanks! You hit the nail on the head.

    WPF css wpf winforms wcf debugging

  • Binding one DP to another across controls
    M MBursill

    If I have two user controls, each with a dependency property, and both those controls are thrown into a grid, how could I bind the results of one of those properties to the other? In short: Control2.Customer = Control1.SelectedCustomer; Where Customer and SelectedCustomer are the two respective DP's. I've tried: The binding doesn't appear to do anything. A breakpoint on the setter of the Customer property never gets hit. Any thoughts? -Mike.

    WPF css wpf winforms wcf debugging

  • Images in a listbox
    M MBursill

    You make mention of a VirtualizingStackPanel, and you show the DataTemplate, but not the ItemsPanel. Good chance you did, but have you tried:

    <ListBox.ItemsPanel>
    <ItemsPanelTemplate>
    <VirtualizingStackPanel/>
    </ItemsPanelTemplate>
    </ListBox.ItemsPanel>

    -Mike.

    WCF and WF wpf wcf performance question

  • Trigger ignored when style added programically
    M MBursill

    I managed to solve this. By giving the first style (the one with the trigger) a key, calling it TextBoxStyle, and adding BasedOn="{StaticResource TextBoxStyle}" to the second style, it works. Don't fully understand why though. -Mike.

    WCF and WF wpf database question

  • Trigger ignored when style added programically
    M MBursill

    I have two simple styles. One with a trigger, setting the background of a TextBox when the IsReadOnly style is true:

    <Style TargetType="{x:Type TextBox}">
    <Style.Triggers>
    <Trigger Property="IsReadOnly" Value="True">
    <Setter Property="Background" Value="{StaticResource TextBoxReadOnlyBackgroundBrush}" />
    </Trigger>
    </Style.Triggers>
    </Style>

    The second style is setting the IsReadOnly property to true:

    <Style TargetType="{x:Type TextBox}">
    <Setter Property="IsReadOnly" Value="True" />
    </Style>

    I add the second style dynamically, like this:

    public void AddReadOnlyStyles()
    {
    ResourceDictionary readOnlyStyles = new ResourceDictionary();
    readOnlyStyles.Source = new Uri("ReadOnlyStyles.xaml");

    if (Resources.MergedDictionaries.Contains(readOnlyStyles) == false)
        Resources.MergedDictionaries.Add(readOnlyStyles);
    

    }

    The read only style is added just fine, but the trigger is ignored. Why is it being ignored? Is there a way to make it so it wont be ignored? Thanks -Mike.

    WCF and WF wpf database question

  • Collapsing cell in uniform grid
    M MBursill

    Thanks for the reply. Setting the columns to 3 works great when I have one of the 4 elements collapsed. The idea was to avoid having to set the columns property dynamically, and have an all XAML solution. In other words, I want the grid to only count columns where the containing element is not collapsed. I was able to do just that by using reflector to dig into the UnformGrid, copy out some of the code, and extend it a bit. If anyone is interested in the code, I'll post it. -Mike.

    WCF and WF css wpf question

  • Collapsing cell in uniform grid
    M MBursill

    I have a simple four column uniform grid:

    <UniformGrid Columns="4">

    <Button>Button 1</Button>
    <Button Visibility="Collapsed">Button 2</Button>
    <Button>Button 3</Button>
    <Button>Button 4</Button>
    

    </UniformGrid>

    I want to distribute the space of the second column when the element is collapsed, essentially making it a three column grid. Is there an all XAML solution to this? I've also tried using a 4 column Grid (not uniform) but set each column's width to *, simulating a uniform grid. Auto sized columns wont work for what I need. Thanks. -Mike.

    WCF and WF css wpf question

  • When to close WCF client?
    M MBursill

    When is it a good time to close a WCF client? Straight from MSDN: http://msdn.microsoft.com/en-us/library/ms751519.aspx[^] It shows:

    CalculatorClient client = new CalculatorClient();

    followed by a bunch of calls to the client, and lastly...

    //Closing the client releases all communication resources.
    client.Close();

    What I really want to know is if it's an okay practice to keep a client open for long periods of time, possibly indefinitely? The reason I would want to do this is because I call a method on my service named "AuthenticateUser" and later I wish to call "GetAuthenticatedUser". If I use the same client object, my returned User object is persisted (without the need to implement a stateful service). I'm having a hard time finding information on what is and isn't good practice when it comes to WCF, specifically on the client side. -Mike.

    WCF and WF question csharp wcf com

  • Role based security
    M MBursill

    I'm playing around with the MMC Authorization Manager attempting to setup some role based security for a new project. The software I'm developing is for a smaller sized businesses. We're the type of place where one day the operations manager is filling the shoes of the accountant because the accountant called in sick, or is on vacation. As a result, my system needs to be flexible when it comes to authorization. I can foresee situations where I may want to allow tasks for a user without necessarily making them part of a role (that would expose everything). Sure I could make additional roles that add only the tasks a specific user may need. If I end up with a lot of specialized cases (which I might) that gets ugly to manage. I really don't want the system to become a nightmare of single-case roles each with one or two users. Has anyone encountered this type of scenario and what was done about it? Also, before the flames start, I realize my question isn't directly related to C# but since there is no security group (And my app is going to be written in C#) this seems the least off topic place to post. Thanks :) -Mike.

    C# security question csharp lounge workspace

  • BindingList over Remoting using an interface types
    M MBursill

    This works without any problems:

    TcpChannel myChannel = new TcpChannel();

    ChannelServices.RegisterChannel(myChannel, false);

    ICustomer objCustomer = (ICustomer)Activator.GetObject(typeof(ICustomer), "tcp://localhost:8000/Customer.rem");
    BindingList<ICustomer> customers = objCustomer.GetCustomers();

    My form has a binding source which I set the DataSource property to the customers object. The form also has a Binding Navigator which pulls form the BindingSource. If I set the AllowNew property on the customers list to true I get the "+" icon on the BindingNavigator. Exactly what I want. However, when I click that icon it attempts to make a new object of the interface type ICustomer. Obviously not possible. So, I handle the AddingNew event of the list with this:

    void customers_AddingNew(object sender, AddingNewEventArgs e)
    {
    ICustomer newCustomer = (ICustomer)Activator.GetObject(typeof(ICustomer), "tcp://localhost:8000/Customer.rem");

    e.NewObject = newCustomer;
    

    }

    Sadly, that gives me the error: "Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed." I've read up on this err and found that if you change the typeFilterLevel of your remoting formatter it would work. I'd prefer not to do that. Info on that was found here: http://www.thinktecture.com/resourcearchive/net-remoting-faq/changes2003 If they changed this behavior in .Net 2.0 than it was probably for a good reason. There has to be another way to do this? Is it not best practice to code towards interface types? What's the solution for dynamic lists over remoting when using interface types? :confused: -Mike.

    C# csharp wpf wcf com security

  • Is it possible to turn off the RowEditing event in a grid view?
    M MBursill

    Thanks, but not exactly what I'm looking for. I want to stop the event form firing all together. -Mike.

    ASP.NET css question

  • Is it possible to turn off the RowEditing event in a grid view?
    M MBursill

    I have a template column in a grid view with a button that has the command name set to "Edit". I handle the button click event myself and do not want the grid to fire the RowEditing event. Is there any to turn this default behavior off? -Mike.

    ASP.NET css question

  • How can I programmatically retrieve the app_data path
    M MBursill

    I managed to solve my own problem, and here it is:

    string strDataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();

    http://blogs.msdn.com/smartclientdata/archive/2005/08/26/456886.aspx -Mike.

    ASP.NET database question regex xml json

  • How can I programmatically retrieve the app_data path
    M MBursill

    That works if I'm trying to resolve a path from a page in the web project. However, I'm trying to accomplish the same from inside a class library referenced by the web project. -Mike.

    ASP.NET database question regex xml json

  • How can I programmatically retrieve the app_data path
    M MBursill

    I have an XML file in my app_data directory. My Data Access layer (a class library project) needs to know where the XML file is. I currently have:

    c:\projects\My website\ (solution file is here)
    c:\projects\My website\website (aspx files, web config, & junk)
    c:\projects\My website\website\app_data\ (a few database files and an xml file)
    c:\projects\My website\websiteDA\ (project folder for data access class library)

    If I add the DA class library project as a reference to my website project, is there any way for the class library to know what the data directory of the website may be. Using something like: XmlTextReader settingsReader = new XmlTextReader("settings.xml"); tells me it's looking in: C:\projects\My website\ the same folder as the solution file. Very odd. I would have expected c:\projects\My website\website DB access gets around this by somehow parsing "|DataDirectory|" in the connection string, resolving it to match the app_data path. Could I do something similar? -Mike.

    ASP.NET database question regex xml json

  • How do I cast a generic list to a generic interface
    M MBursill

    I have the following interface

    public interface IImage
    {
    string FileName { get; set;}
    string Caption { get; set;}
    }

    I have a class called Image that implements the interface. I create a BindingList of that Image object:

    BindingList<Image> images = new BindingList<Image>();

    I later want to store images in a list defined as the interface.

    BindingList<IImage> = images; // casting error

    Why am I getting a casting error? If I understand the rules of polymorphisms correctly, so long as my Image class implements IImage, I can store any Image as an IImage without needing to explicitly cast. What to do? :confused: -Mike.

    C# question help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups