在C#中,我有一个整数值,需要对字符串进行控制,但需要在之前添加零:
例如:
int i = 1;
Run Code Online (Sandbox Code Playgroud)
当我将其转换为字符串时,它需要变为0001
我需要知道C#中的语法.
[DataMember]
public int? NumberOfPages; //////////// Is this supported????
[DataMember]
public bool? Color; //////////// Is this supported????
[DataMember]
public int? BulkQuantity;
[DataMember]
Run Code Online (Sandbox Code Playgroud) 我正在努力在LINQ中获取此SQL查询的结果
SELECT DISTINCT(Type)
FROM Product
WHERE categoryID = @catID
Run Code Online (Sandbox Code Playgroud)
这是我的存储库查询:
public IQueryable<ProdInfo> GetProdInfo()
{
var data = from u in db.Prod
select new ProdInfo
{
PID = u.PID,
CatID = u.CatID,
LastChanged = u.LastChanged,
ChangedBy = u.ChangedBy,
Type = u.Type,
};
return data;
}
Run Code Online (Sandbox Code Playgroud)
过滤:
public static IQueryable<ProdInfo> GetDistinctProdType(this IQueryable<ProdInfo> qry,int CatID)
{
return from p in qry
where p.CatID.Equals(CatID)
select p;
}
Run Code Online (Sandbox Code Playgroud)
我需要过滤器来返回不同的prod类型?我怎样才能做到这一点?
这是我的函数,它将pdf转换为png图像,它在这一行上抛出一个错误 - > stream.WriteTo(Response.OutputStream); 有什么不对??
protected void CreatePngFromPdf()
{
try
{
string PDFLocation = string.Format(@"\\XXXX\{0}\{1}\{2}.pdf", Yr, Loc.Substring(0, 4), Loc.Substring(4, 4));
Utilities.WebPDF.PDF WebPDF = new DocuvaultMVC.Utilities.WebPDF.PDF();
WebPDF.Credentials = new NetworkCredential(@"xyz", "xyz");
byte[] png = WebPDF.StreamPdfPageAsPngResize(PDFLocation,PageNumber, 612, 792);
MemoryStream ms = new MemoryStream(png);
MemoryStream stream = new MemoryStream();
int newWidth = 612;
int newHeight = 792;
System.Drawing.Image newImg = System.Drawing.Image.FromStream(ms);
Bitmap temp = new Bitmap(newWidth, newHeight, newImg.PixelFormat);
Graphics newImage = Graphics.FromImage(temp);
newImage.DrawImage(newImg, 0, 0, newWidth, newHeight);
newImg.Dispose();
temp.Save(stream, ImageFormat.Png);
stream.WriteTo(Response.OutputStream);
temp.Dispose();
stream.Dispose(); …Run Code Online (Sandbox Code Playgroud) <td>
<%= Html.ActionLink("Delete", "DeleteUser", new RouteValueDictionary(new {uname=item.UserName}), new { onclick = "return confirm('Are you sure you want to delete this User?');" }) %>
</td>
Run Code Online (Sandbox Code Playgroud)
在Global.asax.cs中
routes.MapRoute(
"DeleteUser",
"Account.aspx/DeleteUser/{uname}",
new { controller = "Account", action = "DeleteUser", uname = "" }
);
Run Code Online (Sandbox Code Playgroud)
在ActionContorller.cs中
public ActionResult DeleteUser(string uname)
{
//delete user
}
Run Code Online (Sandbox Code Playgroud)
正在传递的控制器中uname的值是空字符串("").
我有一张桌子Product和另一张桌子ProductLog.
日志表需要跟踪表中的两列Product.每次在这些列上都有插入,更新或删除时,我需要更新日志表.
我是否需要编写三个单独的触发器,或者一个触发器可以处理这些操作?
我还需要知道操作的类型,例如,我需要知道日志表中的条目是否是因为插入或删除或更新.如果有人给我一个很好的例子.
这是不正确的,我们不能动态地将表名传递给选择查询吗?
这给了我一个错误'必须声明表变量@TblName'
DECLARE @TblName VARCHAR(30)
SET @TblName = 'User'
SELECT *
FROM @TblName
Run Code Online (Sandbox Code Playgroud) 我有一个 Web 服务,它位于这样的反向代理后面:

现在发生的情况是,当我尝试添加 Web 引用来测试 Web 服务时,它说无法下载 wsdl 文件。那是因为当请求被发送时它是https://uat.mywebservice.com/Service/Service.asmx但是当它击中反向代理然后厌倦下载 wsdl 和迪斯科文件时,它会将链接更改为http: //myservice.comp.com/Service/Service.asmx?wsdl这不是正确的链接,因为myservice.comp.com它只是反向代理上的名称空间。
发生的事情是soap文件中的标题被更新到这个命名空间而不是实际的主机名uat.mywebservice.com,我能够看到使用fiddler disco文件的地址不正确。我通过使用 wsdl.exe 工具创建一个代理类,然后将该类中的所有错误链接更新为正确的主机名。
有什么方法可以确保在点击反向代理时地址保持正确。
不正确: mywebservice.comp.com
<?xml version="1.0" encoding="utf-8" ?>
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
<contractRef ref="http://mvwebservice.comp.com/Service/Service.asmx?wsdl" docRef="http://mvwebservice.comp.com/Service/Service.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />
<soap address="http://mywebservice.comp.com/Service/Service.asmx" xmlns:q1="http://tempuri.org/" binding="q1:ServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
<soap address="http://mywebservice.comp.com/Service/Service.asmx" xmlns:q2="http://tempuri.org/" binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
</discovery>
Run Code Online (Sandbox Code Playgroud)
正确的: uat.mywebservice.com
<?xml version="1.0" encoding="utf-8" ?>
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
<contractRef ref="https://uat.mvwebservice.com/Service/Service.asmx?wsdl" docRef="https://uat.mvwebservice.com/Service/Service.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />
<soap address="https://uat.mywebservice.com/Service/Service.asmx" xmlns:q1="http://tempuri.org/" binding="q1:ServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
<soap address="https://uat.mywebservice.com/Service/Service.asmx" xmlns:q2="http://tempuri.org/" binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" …Run Code Online (Sandbox Code Playgroud) 我在尝试访问wcf Web服务时遇到此异常.
[WebException: The remote server returned an error: (400) Bad Request.]
System.Net.HttpWebRequest.GetResponse() +5314029
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +54
Run Code Online (Sandbox Code Playgroud)
服务器绑定信息
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wcfSmartConnect" closeTimeout="10:01:00"
maxBufferSize="104857600" maxBufferPoolSize="104857600"
maxReceivedMessageSize="104857600" openTimeout="10:01:00"
receiveTimeout="10:10:00" sendTimeout="10:01:00"
messageEncoding="Mtom" transferMode="StreamedRequest">
<readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
maxArrayLength="104857600" maxBytesPerRead="104857600"
maxNameTableCharCount="104857600" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WcfSmartConnect.Service1"
behaviorConfiguration="WcfSmartConnect.Service1Behavior">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="wcfSmartConnect"
contract="WcfSmartConnect.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfSmartConnect.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
客户端绑定信息
<system.serviceModel>
<bindings>
<basicHttpBinding> …Run Code Online (Sandbox Code Playgroud) 考虑这段代码:
public class CountEnum : EnumDataType
{
public static readonly CountEnum CANADA = new CountEnum("CA", "Canada");
public static readonly CountEnum DEFAULT = new CountEnum();
private static readonly EnumDataTypeList OPTIONS = new EnumDataTypeList();
public static readonly CountEnum UNITED_STATES = new CountEnum("US", "United States");
public static readonly CountEnum UNSET = new CountEnum();
private CountEnum()
{
}
private CountEnum(string code, string name)
{
base.code = code;
base.name = name;
OPTIONS.Add(this); // This is the line 23
}
Run Code Online (Sandbox Code Playgroud)
以下是异常详细信息:
System.TypeInitializationException was caught
Message=The type …Run Code Online (Sandbox Code Playgroud) c# ×4
asp.net ×3
asp.net-mvc ×2
sql-server ×2
wcf ×2
.net ×1
asmx ×1
datatrigger ×1
exception ×1
formatting ×1
linq ×1
t-sql ×1
web-services ×1