C# DevForce实体的客户端部分无法看到部分模型中公开的属性

C# DevForce实体的客户端部分无法看到部分模型中公开的属性,c#,wpf,devforce,C#,Wpf,Devforce,我目前面临的一个问题是,我试图使WPF客户端成为我们的Model First DevForce实体之一的一部分。问题是WPF客户端中的分部似乎无法访问客户端项目引用的模型项目中其同级分部中的属性 我在客户机和模型中都使用了相同的名称空间,但客户机端不断返回,因为它是一个只有一个文件的分部 我的主要理由是,我需要访问静态类的属性,该静态类位于我要添加到客户端实体的属性中的客户端项目中。其样本如下: 模型伙伴类: using System; using System.ComponentModel.D

我目前面临的一个问题是,我试图使WPF客户端成为我们的Model First DevForce实体之一的一部分。问题是WPF客户端中的分部似乎无法访问客户端项目引用的模型项目中其同级分部中的属性

我在客户机和模型中都使用了相同的名称空间,但客户机端不断返回,因为它是一个只有一个文件的分部

我的主要理由是,我需要访问静态类的属性,该静态类位于我要添加到客户端实体的属性中的客户端项目中。其样本如下:

模型伙伴类:

using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Security.Principal;
using IbEm = IdeaBlade.EntityModel;
using IdeaBlade.EntityModel.Security;
using IdeaBlade.Validation;

// ReSharper disable CheckNamespace
namespace BearPaw.Models.Main
{
[MetadataType(typeof(NavigationButtonGroupMetadata))]
public partial class NavigationButtonGroup
{

    [IbEm.AllowRpc]
    public static object NameAlreadyInUse(IPrincipal principal,
      IbEm.EntityManager entityManager, params Object[] args)
    {
        string buttonGroupNameToCheck = (string)args[0];

        var serverButtonGroup = entityManager.GetQuery<NavigationButtonGroup>().FirstOrDefault((u) => u.Name == buttonGroupNameToCheck);

        return serverButtonGroup != null;
    }

}

public class NavigationButtonGroupMetadata
{
    [RegexVerifier("Name", @"^[A-Za-z_]*$")]
    [StringLengthVerifier(MaxValue = 100, IsRequired = true, ErrorMessage = "Button Group Name must be unique")]
    public static string Name;
}

}
Visual Studio在NavigationButtongGroupType.AlwaysVisible上显示编译错误,说明非静态字段需要对象引用,即使NavigationButtongGroupType是模型中实体上的导航属性。类似的问题也适用于NavigationButtons也是nav属性,但Visual Studio声明它在当前上下文中不存在

如果您能提供任何帮助或指点,说明为什么这样做行不通,我们将不胜感激

非常感谢


Lee

局部类定义允许您将类定义扩展到多个文件,但只能在同一程序集中。这是一个C#东西,不是一个DevForce限制。有关更多信息,请参阅

如果我理解正确,那么您希望实体类的某些功能仅在客户机上可用(还有一些在服务器上?)。如果要定义客户机和服务器模型项目,可以使用条件编译来确定每个程序集中实体的哪些功能可用。这在DevForce SL应用程序中是相当标准的,尽管在WPF中可能很少使用


如果您使用这种类型的体系结构,另一种选择是将类似的属性放入ViewModel中。

Hi Kim,谢谢。我想我是在误导自己,因为IdeaBrade DRC中的以下文字“一种更干净、更简单的方法是在.NET项目或客户端项目中创建额外的部分类文件,并故意不链接它们。”这让我觉得有一些“秘方”可以允许这样做。这段代码是为一些导航结构编写的,我希望不必为了保存结构和实体而编写一个完整的VM,看起来我可能不得不重新思考我的猜测。谢谢你的快速回复。
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Security.Principal;
using IbEm = IdeaBlade.EntityModel;
using IdeaBlade.EntityModel.Security;
using IdeaBlade.Validation;

// ReSharper disable CheckNamespace
namespace BearPaw.Models.Main
{
[MetadataType(typeof(NavigationButtonGroupMetadata))]
public partial class NavigationButtonGroup
{
    public bool IsEnabled
    {
        get
        {
            {
                if (NavigationButtonGroupType.AlwaysVisible || (DynamicMenuItemsHelper.MenuDetails != null && DynamicMenuItemsHelper.MenuDetails.Count() > 0 )) return true;
                var currentUser = Authenticator.Instance?.DefaultAuthenticationContext?.Principal?.Identity;
                return currentUser != null && NavigationButtons.
                    Any(b => b.IsEnabled);
            }
        }
    }
}
}