小编Apo*_*nas的帖子

使用具有多个数据库架构但使用一个DBContext的实体框架6

我有一个使用EF作为ORM的应用程序.数据库曾经有一个架构,dbo,一切都运行正常.我最近将我的表组织成4种不同的模式.一个模式的某些表依赖于驻留在不同模式上的表.所有似乎都在SQL方面有效.

在应用程序端,通过EF的所有数据库交互都不再起作用.代码编译,模式在解决方案中可见,模型映射指向正确的模式,但是一旦我尝试向表中插入行,它就不起作用.

我看过一些关于使用多个模式的帖子需要使用多个DBContexts,但我宁愿使用一个DBContext.我的所有模式都拥有相同的所有者dbo,我没有看到使用多个DBContexts的原因.

有谁知道是否有办法实现这一目标?

entity-framework db-schema dbcontext

29
推荐指数
3
解决办法
1万
查看次数

Monotouch.Dialog StyledStringElement委托总是为最后添加的元素触发

给出以下代码,单击每个元素时遇到问题.如果我们假设我有5个练习,因此在foreach()循环中创建了5个元素,当表格被渲染并且我点击任何元素时,委托总是得到第5个(最后一个)元素的练习.

元素显示正确,每个元素显示相关练习的名称.只是委托不能按预期工作.

如果我不使用foreach循环并对每个元素进行硬编码,则它会按预期工作.但是如果我不能动态填充dialogViewController并为每一个使用元素tapped事件,那就不好了.

private void CreateExerciseTable()
{
Section section = new Section();

foreach (var exercise in exercises)
{
    var element = new StyledStringElement(exercise.ExerciseName, 
        delegate { AddExercise(exercise); }) 
        {
            Font = Fonts.H3,
            TextColor = UIColor.White,
            BackgroundColor = RGBColors.LightBlue,
            Accessory = UITableViewCellAccessory.DisclosureIndicator
        };

    section.Elements.Add(element);
}

var root = new RootElement("Selection") {
    section
};

 var dv = new DialogViewController(root, true);
dv.Style = UITableViewStyle.Plain;

//Remove the extra blank table lines from the bottom of the table.
UIView footer = new UIView(new System.Drawing.RectangleF(0,0,0,0));
dv.TableView.TableFooterView = …
Run Code Online (Sandbox Code Playgroud)

xamarin.ios dialogviewcontroller

2
推荐指数
1
解决办法
1256
查看次数