使用EF代码第一种方法和关联,我是一个非常奇怪的行为.我有两个实体:
public class GlobalKpiSectionn
{
public GlobalKpiSection()
{
this.Regions = new HashSet<Region>();
}
public virtual ICollection<Region> Regions { get; protected set; }
}
public class Region
{
public int RegionId { get; set; }
public bool IsMain { get; set; }
[Required]
public virtual GlobalKpiSection KpiSection { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我需要KiSection属性的必需属性才能获得级联删除.
问题是以下 - 在此代码中:
var mainRegion = context.Regions.Single(x => x.RegionId == id);
mainRegion.IsMain = true;
context.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
我得到的例外是必填字段未初始化.但它是目前只是没有加载.当我使用这个实体时,我不会写任何明确包含属性的内容.我该怎么做才能克服这个问题?
UPDATE
我之所以确定它的延迟加载问题是因为:
var primaryRegion = context.Regions
.Include(x => x.KpiSection)
.Single(x …Run Code Online (Sandbox Code Playgroud) 目前,当我在本地功能分支上工作以获取最新更改时,我需要执行以下操作:
git checkout master
git fetch
git rebase
git checkout my-feature
git rebase master
Run Code Online (Sandbox Code Playgroud)
是否有更简单的解决方案,只需将更改拉到主分支而不切换到它?
在 .net 4.5 的更改日志中提到了这个新设置
<configuration>
<!-- ... -->
<runtime>
<performanceScenario value="HighDensityWebHosting" />
<!-- ... -->
Run Code Online (Sandbox Code Playgroud)
但是对于此设置实际影响的内容,确实没有很好的描述,我们是否应该在生产中安装 .net 4.5 后费心更改它。有人可以分享有关此设置究竟发生了什么变化的任何详细信息吗?
目前我正在使用这个插件来获取visual studio中的咖啡脚本.但是在相对较小的脚本上,它的工作速度很慢 还有其他VS插件具有更好的性能吗?
我知道有很多关于此问题的文章。但是我努力挣扎了两周,没有成功。
我正在尝试使用github上描述的最佳实践。所以我添加了一个.gitattributes文件,例如,它看起来像这样:
*.cs text
Run Code Online (Sandbox Code Playgroud)
而且我已经标准化了所有文件的行尾。现在,我有干净的工作副本,无须提交。但是现在,如果我在任何Windows文本编辑器中都打开了文件并进行了一些随机更改,请保存文件,然后撤消该更改,我会看到此文件已更改。我了解这是因为文件现在具有Windows样式行的结尾。但这是一种可怕的工作方式,文件没有更改,我希望git在没有它的情况下知道它git reset --hard。在这种情况下,您会推荐什么?
我添加了一个文件env.conf,内容如下
MONO_GC_PARAMS=bridge-implementation=tarjan
MONO_GC_PARAMS=nursery-size=128m
MONO_GC_PARAMS=soft-heap-limit=512m
Run Code Online (Sandbox Code Playgroud)
到我的Android项目并将其构建操作配置为AndroidEnvironment。不幸的是,应用程序的输出表明旧的桥实现用于垃圾回收:
07-09 09:43:34.042 D / Mono(32084):GC_OLD_BRIDGE num-objects 228 num_hash_entries 20scsc大小1277 init 0.00ms df1 7.35ms排序2.87ms dfs2 2.96ms setup-cb 0.40ms免费数据3.11ms链接2593 / 2593/1284/16 DFS通过4870/3870
07-09 09:43:34.042 D /单声道(32084):GC_MAJOR:(LOS溢出)暂停60.33ms,总计61.31ms,桥接45.65ms主6864K / 6608K los 510K / 12016K
我正在使用Xamarin 3.11.666.0和Xamarin.Android 5.1.4.16,它似乎是这些软件包的最新版本。
如何为应用程序应用新的网桥实现?
我有以下类层次结构
class Test
{
public string Name { get; set; }
}
class TestChild : Test
{
public string Surname { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我无法改变Test类.我想写下面这样的扩展方法:
static class TestExtensions
{
public static string Property<TModel, TProperty>(this Test test, Expression<Func<TModel, TProperty>> property)
{
return property.ToString();
}
}
Run Code Online (Sandbox Code Playgroud)
能够以下列方式使用它:
class Program
{
static void Main(string[] args)
{
TestChild t = new TestChild();
string s = t.Property(x => x.Name);
}
}
Run Code Online (Sandbox Code Playgroud)
但现在编译说
无法从用法中推断出方法"ConsoleApplication1.TestExtensions.Property(ConsoleApplication1.Test,System.Linq.Expressions.Expression>)"的类型参数.尝试显式指定类型参数.
我希望有类似mvc Html.TextBoxFor(x => x.Name)方法的东西.是否可以编写扩展以便如Main方法中所示使用?
我正在尝试使用TeamCity在x64机器上为.net 4设置partcover.
测试已执行,但覆盖率报告显示0覆盖范围.
我在日志中收到以下消息:
No executable code was detected.
The issue could be caused by one of the following:
- Include / exclude patterns are incorrect
- Assemblies are compiled without debugging information
- .pdb files are not available
- Visual Studio code coverage is enabled for MSTest
- .testrunconfig is used for MSTest and Visual Studio code coverage is not disabled (CodeCoverage section with enable="true" is present)
Run Code Online (Sandbox Code Playgroud)
但包含模式是[*]*.
如果重要的话,我正在运行TeamCity 6.5.3.有没有人设法在该版本上运行partcover?
在链接器任务中升级到mvvmcross 4.1后获取编译错误:
The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Boolean MvvmCross.Droid.Shared.Attributes.MvxFragmentAttributeExtensionMethods::IsFragmentCacheable(System.Type)' (defined in 'MvvmCross.Droid.Support.V7.Fragging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'MvvmCross.Droid.Support.V7.Fragging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Boolean MvvmCross.Droid.Shared.Attributes.MvxFragmentAttributeExtensionMethods::IsFragmentCacheable(System.Type)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, …
.net ×3
android ×2
git ×2
mono ×2
xamarin ×2
asp.net ×1
branch ×1
c# ×1
code-first ×1
coffeescript ×1
expression ×1
git-checkout ×1
git-pull ×1
iis ×1
intellisense ×1
lambda ×1
lazy-loading ×1
mvvmcross ×1
nhibernate ×1
partcover ×1
teamcity ×1
teamcity-6 ×1
validation ×1
windows ×1