小编Den*_*nis的帖子

如何在没有 SQL Server Management Studio 的情况下使用 SQL Server Express LocalDB 中的 Visual Studio 2013 创建两个表之间的关系?

我可以通过在 Visual Studio 2010 中右键单击并选择表设计器中的关系,使用 SQL Server Express 非常轻松地创建表关系。如何在不使用 SQL Server Management Studio 的情况下使用 SQL Server Express LocalDB 中的 Visual Studio 2013 创建两个表之间的关系?我对此很困惑。可能没有 T-SQL 代码。我想要一个简单的解决方案。

table-relationships localdb visual-studio-2013

5
推荐指数
1
解决办法
3102
查看次数

不能跳出finally块

我正在尝试从函数返回一个值。该函数WcfProvider.MetalsPrices可能会抛出异常。我想避免它。

public IEnumerable<PriceOfMetal> GetPrice(int id, DateTime time)
{
        bool condition = false;
        DateTime timenew = time.AddDays(-1);

        var allPrice = from c in db.PriceOfMetal
                       select c;

        foreach (var i in allPrice)
        {
            if (i.Date.Date == timenew.Date && i.ListOfMetaL_Id==id)
            {
                condition = true;
            }
        }

        try
        {
            if (condition == false)
            {
                var price = WcfProvider.MetalsPrices(id, time, time).Tables[0].AsEnumerable()
                    .Select(
                        a =>
                            new PriceOfMetal()
                            {
                                Date = a.Field<DateTime>("Date"),
                                ListOfMetaL_Id = a.Field<int>("MetalId"),
                                Value = a.Field<System.Double>("Price")
                            })
                    .ToList().Single();

                db.PriceOfMetal.Add(price);
                db.SaveChanges();
            }
        }
        finally …
Run Code Online (Sandbox Code Playgroud)

c# try-catch

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