我目前收到此错误:
System.Data.SqlClient.SqlException:不允许新事务,因为会话中还有其他线程在运行.
在运行此代码时:
public class ProductManager : IProductManager
{
#region Declare Models
private RivWorks.Model.Negotiation.RIV_Entities _dbRiv = RivWorks.Model.Stores.RivEntities(AppSettings.RivWorkEntities_connString);
private RivWorks.Model.NegotiationAutos.RivFeedsEntities _dbFeed = RivWorks.Model.Stores.FeedEntities(AppSettings.FeedAutosEntities_connString);
#endregion
public IProduct GetProductById(Guid productId)
{
// Do a quick sync of the feeds...
SyncFeeds();
...
// get a product...
...
return product;
}
private void SyncFeeds()
{
bool found = false;
string feedSource = "AUTO";
switch (feedSource) // companyFeedDetail.FeedSourceTable.ToUpper())
{
case "AUTO":
var clientList = from a in _dbFeed.Client.Include("Auto") select a;
foreach (RivWorks.Model.NegotiationAutos.Client client in clientList)
{ …
Run Code Online (Sandbox Code Playgroud) 我有一个包含所有接口定义
的项目:RivWorks.Interfaces 我有一个项目,我定义了具体的实现:RivWorks.DTO
我之前已经完成了数百次但由于某种原因我现在收到此错误:
无法将类型'System.Collections.Generic.List <RivWorks.DTO.Product>'隐式转换为'System.Collections.Generic.List <RivWorks.Interfaces.DataContracts.IProduct>'
接口定义(缩写):
namespace RivWorks.Interfaces.DataContracts
{
public interface IProduct
{
[XmlElement]
[DataMember(Name = "ID", Order = 0)]
Guid ProductID { get; set; }
[XmlElement]
[DataMember(Name = "altID", Order = 1)]
long alternateProductID { get; set; }
[XmlElement]
[DataMember(Name = "CompanyId", Order = 2)]
Guid CompanyId { get; set; }
...
}
}
Run Code Online (Sandbox Code Playgroud)
具体类定义(缩写):
namespace RivWorks.DTO
{
[DataContract(Name = "Product", Namespace = "http://rivworks.com/DataContracts/2009/01/15")]
public class Product : IProduct
{
#region Constructors
public Product() { }
public …
Run Code Online (Sandbox Code Playgroud) 我在基于C#的代码中使用Entity Framework.我遇到了意想不到的怪异,正在寻找建议.
案例1,2,3,4 ......项目:
RivWorks.dll
RivWorks.Service.dll
RivWorks.Alpha.dll
样本(所有这些工作):
RivWorks.Alpha.dll:
public static bool EndNegotitation(long ProductID)
{
var product = (from a in _dbFeed.AutoWithImage
where a.AutoID == ProductID select a).FirstOrDefault();
...
}
Run Code Online (Sandbox Code Playgroud)
RivWorks.Service.dll
public static RivWorks.Model.NegotiationAutos.AutoWithImage
GetProductById(long productId)
{
var myProduct = from a in _dbFeed.AutoWithImage
where a.AutoID == productId select a;
return myProduct.FirstOrDefault();
}
public static List<RivWorks.Model.NegotiationAutos.AutoWithImage>
GetProductByCompany(Guid companyId)
{
var myProduct = from a in _dbFeed.AutoWithImage
where a.CompanyID == companyId select a;
return myProduct.ToList();
}
Run Code Online (Sandbox Code Playgroud)
等等
案例"怪异":
RivWorks.Web.Service.dll(WCF项目)
包含与其他项目相同的引用.
public …
Run Code Online (Sandbox Code Playgroud) 我有一个在客户端页面(跨域,而不是我们的IIS服务器等)上运行的HttpHandler,当他们点击我们的嵌入式链接时,它会触发我们服务器上的Handler.到目前为止一切正常.
我现在正在尝试使用System.Web.HttpContext.Session对象,但它为null.我认为它是null,因为我们在调用HttpHandler之前没有会话?多次调用处理程序会在每次调用时创建一个新会话?如果是这种情况,MS只是在调用HttpHandler时禁用了Session对象吗?谁能证实这一点?
如果是这种情况,您如何维持呼叫之间的状态?某种基于SQL的数据对象?一份文件?
TIA
将动态WHERE子句组装到LINQ语句的最佳方法是什么?
我在表单上有几十个复选框,并将它们传递回:Dictionary <string,List <string >>(Dictionary <fieldName,List <values >>)到我的LINQ查询.
public IOrderedQueryable<ProductDetail> GetProductList(string productGroupName, string productTypeName, Dictionary<string,List<string>> filterDictionary)
{
var q = from c in db.ProductDetail
where c.ProductGroupName == productGroupName && c.ProductTypeName == productTypeName
// insert dynamic filter here
orderby c.ProductTypeName
select c;
return q;
}
Run Code Online (Sandbox Code Playgroud) 有一点背景:
我有一个DLL项目具有以下结构:
Rivworks.Model (project)
\Negotiation (folder)
Model.edmx (model from DB #1)
\NegotiationAutos (folder)
Model.edmx (model from DB #2)
Run Code Online (Sandbox Code Playgroud)
我已将连接字符串从此项目的app.config移动到web.config文件.它们不在 ConnectionString部分中.相反,我有一个静态类,它消耗部分web.config并将它们作为AppSettings公开给我的应用程序.[settingName].
<FeedAutosEntities_connString>metadata=res://*/;provider=System.Data.SqlClient;provider connection string='Data Source=db4;Initial Catalog=RivFeeds;Persist Security Info=True;User ID=****;Password="****";MultipleActiveResultSets=True'</FeedAutosEntities_connString>
<RivWorkEntities_connString>metadata=res://*/NegotiationAutos.NegotiationAutos.csdl|res://*/NegotiationAutos.NegotiationAutos.ssdl|res://*/NegotiationAutos.NegotiationAutos.msl;provider=System.Data.SqlClient;provider connection string='Data Source=db2;Initial Catalog=RivFramework_Dev;Persist Security Info=True;User ID=****;Password="****";MultipleActiveResultSets=True'</RivWorkEntities_connString>
Run Code Online (Sandbox Code Playgroud)
我有2个类,每个上下文一个,它们看起来像这样:
namespace RivWorks.Model
{
public class RivWorksStore
{
private RivWorks.Model.Negotiation.Entities _dbNegotiation;
public RivWorksStore(string connectionString, string metadata, string provider)
{
EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
entityBuilder.ConnectionString = connectionString;
entityBuilder.Metadata = "res://*/"; // metadata;
//entityBuilder.Provider = provider;
_dbNegotiation = new RivWorks.Model.Negotiation.Entities(entityBuilder.ConnectionString);
}
public RivWorks.Model.Negotiation.Entities NegotiationEntities() …
Run Code Online (Sandbox Code Playgroud) 我在https://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/4d45e9ea5471cba4/4519371a77ed4a74?hl=en&pli=1上发布了一些示例代码, 用于自行安装Windows服务.我在fx 4.0的C#中.试图找出我离开轨道的地方......
我的问题:
当应用程序没有控制台或从文件重定向控制台输入时,无法读取密钥.试试Console.Read.
我的代码和东西:
我的项目结构的图像:
注意:在DEBUG模式下,我在TestHarness中复制了启动顺序.如果/当我开始工作时,我会从解决方案中删除它.图书馆项目是我的大多数代码所在的地方.
Program.cs中
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.ComponentModel;
using System.Configuration.Install;
using System.Collections;
using RivWorks.FeedHandler.Service;
namespace RivWorks.FeedHandler
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static int Main(string[] args)
{
bool install = false, uninstall = false, console = false, rethrow = false;
try
{
foreach (string …
Run Code Online (Sandbox Code Playgroud) mscorlib.dll中发生未处理的"System.StackOverflowException"类型异常
确保您没有无限循环或无限递归.
以下代码在此方法成功时调用:
internal static List<RivWorks.Model.Negotiation.ProductsSold> GetProductsSoldByCompany(Guid CompanyID)
{
var ret = from a in _dbRiv.ProductsSold where a.Company.CompanyId == CompanyID select a;
return ret.ToList();
}
Run Code Online (Sandbox Code Playgroud)
在返回时,它调用实体模型并尝试填充所有外键控对象(子对象).架构是[1公司有0到多个ProductsSold].出于某种原因,对以下代码的调用只会自行级联:
[global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("RIV_Model", "FK_ProductsSold_Company", "Company")]
[global::System.Xml.Serialization.XmlIgnoreAttribute()]
[global::System.Xml.Serialization.SoapIgnoreAttribute()]
[global::System.Runtime.Serialization.DataMemberAttribute()]
public Company Company
{
get
{
return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Company>("RIV_Model.FK_ProductsSold_Company", "Company").Value;
}
set
{
((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Company>("RIV_Model.FK_ProductsSold_Company", "Company").Value = value;
}
}
/// <summary>
/// There are no comments for Company in the schema.
/// </summary>
[global::System.ComponentModel.BrowsableAttribute(false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
public global::System.Data.Objects.DataClasses.EntityReference<Company> CompanyReference
{
get
{
return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Company>("RIV_Model.FK_ProductsSold_Company", "Company");
}
set
{
if ((value …
Run Code Online (Sandbox Code Playgroud) 我有一个JSONP WCF端点,我试图找出为什么我得到504错误.
HTTP/1.1 504 Fiddler - 接收失败
内容类型:text/html
连接:close
时间戳:11:45:45:9580
ReadResponse()失败:服务器未返回此请求的响应.
我可以在我的Endpoint内部的任何地方设置一个断点,逐步执行代码,看到它成功收集响应所需的数据,点击最后一行代码,然后一旦我退出WCF调用,我就得到504错误. 这是在上周工作!
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceContract(Name = "NegotiateService", Namespace = "http://rivworks.com/Services/2009/01/15")]
public class NegotiateService //: svcContracts.INegotiateService
{
public NegotiateService() { }
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public dataObjects.NegotiateSetup GetSetup(string method, string jsonInput)
{
dataObjects.NegotiateSetup resultSet = new dataObjects.NegotiateSetup();
using (RivFeedsEntities1 _dbFeed = new FeedStoreReadOnly(AppSettings.FeedAutosEntities_connString, "", "").ReadOnlyEntities())
{
using (RivEntities _dbRiv = new RivWorksStore(AppSettings.RivWorkEntities_connString, "", "").NegotiationEntities())
{
// Deserialize the input and get all the data we need...
Newtonsoft.Json.Linq.JObject o = …
Run Code Online (Sandbox Code Playgroud) 我下拉的基础HTML有可能改变,我试图使用.live
选项而不是.change
选项来设置它.它对我不起作用.
我现在拥有的是:
$("#ItemsPerPage").change(function(e) { return updatePaging(); });
Run Code Online (Sandbox Code Playgroud)
不幸的是,如果我通过$.ajax
它更新此控件会丢失事件定义.我尝试过但不起作用的是:
$("#ItemsPerPage").live("change", function(e) { return updatePaging(); });
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
c# ×7
.net ×2
asp.net ×1
c#-4.0 ×1
console ×1
dynamic ×1
httphandler ×1
interface ×1
jquery ×1
lambda ×1
linq ×1
recursion ×1
transactions ×1
wcf ×1
where-clause ×1