小编Mar*_*kGr的帖子

实体框架 - 如何在辅助表中的非主键列上连接表?

我想使用实体框架加入2个表.我希望第二个表的连接位于非主键列上.

例如,我有一个带有字段的表Foo

Foo.Id (PK)
Foo.DbValue
Run Code Online (Sandbox Code Playgroud)

和桌子吧

Bar.Id (PK)
Bar.DbValue
Bar.Description
Run Code Online (Sandbox Code Playgroud)

我想在DbValue领域加入Foo到EF的Bar.

在hibernate/nhibernate中,可以通过向多对一添加列参数来实现.大致是这样的

<class name="Foo" table="Foo>
  <id name="Id" column="Id" />
  <many-to-one name="Bar" class="Bar" column="**DbValue**" />
</class>
Run Code Online (Sandbox Code Playgroud)

如果有人知道如何在EF中这样做,请提前感谢.

c# mapping entity-framework join foreign-keys

8
推荐指数
1
解决办法
5960
查看次数

通过网络在app.config中加载具有WCF behaviorExtension的应用程序时出现SecurityException

我有一个.NET 4 .exe(Winform桌面应用程序),我添加了一个WCF behaviorExtension.应用程序在本地计算机上加载正常,但在通过网络加载时会抛出SecurityException.如果我省略了setMaxFaultSizeBehavior behaviorExtension,那么我可以通过网络加载应用程序.我将不胜感激任何有助于实现这一目标的信息.我已确认文件未被阻止,并且程序集名称完全匹配,包括空格.

app.config的相关部分看起来像这样(我缩短了类型名称和程序集名称,在实际的配置文件中,我使用完整的命名空间和程序集名称):

<system.serviceModel>
    <bindings configSource="bindings.config" />
    <client configSource="clients.config" />
    <extensions>
      <behaviorExtensions>
        <add name="setMaxFaultSizeBehavior" type="SetMaxFaultSizeBehavior, BehaviorAssembly, Version=1.8.0.0, Culture=neutral, PublicKeyToken=41b332442f1101cc" />
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <endpointBehaviors>
       <behavior name="LargeQuotaBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483600" />
          <setMaxFaultSizeBehavior />
       </behavior>
      </endpointBehaviors>
    </behaviors>
Run Code Online (Sandbox Code Playgroud)

通过网络运行时遇到的异常是:

An error occurred creating the configuration section handler for system.serviceModel/behaviors: Request failed. (\\server\Share\app.exe.Config line 22)
Exception Type: System.Configuration.ConfigurationErrorsException
Source: System.Configuration
Run Code Online (Sandbox Code Playgroud)

具有System.Security.SecurityException的内部异常

.net wcf securityexception wcf-behaviour

6
推荐指数
1
解决办法
1623
查看次数