我有以下方法在数据库中注册联系人,但在注册之前我检查联系人是否存在:
<asp:FormView ID="fvWebDescription" CssClass="webdescription" runat="server" DataKeyNames="id, type"
DataSourceID="sdsWebVisitorsDescription">
<EditItemTemplate>
<custom:CustomEditor ID="txtDescription" runat="server" Content='<%# Bind("content") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update" /> | <asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
<custom:CustomEditor ID="txtDescription" runat="server" Content='<%# Bind("content") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" /> | <asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="contentLabel" runat="server" Text='<%# Bind("content") %>' />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" OnCommand="loadDescription" CommandArgument="web" />
</ItemTemplate>
<EmptyDataTemplate>This business does not have a description for website visitors. Please
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
CommandName="New" Text="click here" /> to add one.</EmptyDataTemplate>
</asp:FormView>
此查询包含搜索条件中包含值(非空)的字段(FilesID,EmailAddress,DisplayName)
这种技术在MSSQL中工作正常,今天我将数据库管理器改为PostgreSQL并使用Npgsql。
除了上面的linq查询之外,所有工作都有效,它引发了一个异常消息:“无法确定参数$ 2的数据类型”
我被迫以这种方式解决它:
$(document).delegate(('.webdescription body'), "click", function () {
console.log(this).text();
});
这是Npgsql错误还是设计错误?该问题的任何已知解决方案/解决方法?
答案 0 :(得分:0)
我目前有同样的情况。我认为问题是NpgSQL缺乏对string.IsNullOrEmpty的认可。
我用空字符串检查替换了测试,始终将输入参数识别为非空。
- 糟糕
var data = from art in _ctx.Set<Soleo.Model.DLAR>()
from iva in _ctx.Set<Soleo.Model.DLAI>().Where(k => k.DITTA == art.DITTA && k.COD == art.CIVA).DefaultIfEmpty()
from fam in _ctx.Set<Soleo.Model.DLFA>().Where(k => k.DITTA == art.DITTA && k.COD == art.FAM).DefaultIfEmpty()
from mar in _ctx.Set<Soleo.Model.DLMA>().Where(k => k.DITTA == art.DITTA && k.COD == art.MAR).DefaultIfEmpty()
from udm in _ctx.Set<Soleo.Model.DLUM>().Where(k => k.DITTA == art.DITTA && k.COD == art.UM).DefaultIfEmpty()
where art.DITTA == DLAUTH.Config.Current.DITTA && art.COD.Contains(sel_cod) && art.DES.Contains(sel_des)
&& (string.IsNullOrEmpty(sel_fam) || string.Compare(art.FAM, sel_fam, true) == 0)
&& (string.IsNullOrEmpty(sel_mar) || string.Compare(art.MAR, sel_mar, true) == 0)
&& (art.DIS >= sel_dis_da && art.DIS <= sel_dis_a)
select new
{
COD = art.COD,
DES = art.DES,
DES_UDM = udm.DES,
DES_MAR = mar.DES,
DES_FAM = fam.DES,
DES_CIVA = iva.DES,
MAG1 = art.MAG1,
MAG2 = art.MAG2,
DES_DIS = art.DIS == 1 ? "Si" : "No"
};
- 好:
var data = from art in _ctx.Set<Soleo.Model.DLAR>()
from iva in _ctx.Set<Soleo.Model.DLAI>().Where(k => k.DITTA == art.DITTA && k.COD == art.CIVA).DefaultIfEmpty()
from fam in _ctx.Set<Soleo.Model.DLFA>().Where(k => k.DITTA == art.DITTA && k.COD == art.FAM).DefaultIfEmpty()
from mar in _ctx.Set<Soleo.Model.DLMA>().Where(k => k.DITTA == art.DITTA && k.COD == art.MAR).DefaultIfEmpty()
from udm in _ctx.Set<Soleo.Model.DLUM>().Where(k => k.DITTA == art.DITTA && k.COD == art.UM).DefaultIfEmpty()
where art.DITTA == DLAUTH.Config.Current.DITTA && art.COD.Contains(sel_cod) && art.DES.Contains(sel_des)
&& (string.Compare(sel_fam, "", true) == 0 || string.Compare(art.FAM, sel_fam, true) == 0)
&& (string.Compare(sel_mar, "", true) == 0 || string.Compare(art.MAR, sel_mar, true) == 0)
&& (art.DIS >= sel_dis_da && art.DIS <= sel_dis_a)
select new
{
COD = art.COD,
DES = art.DES,
DES_UDM = udm.DES,
DES_MAR = mar.DES,
DES_FAM = fam.DES,
DES_CIVA = iva.DES,
MAG1 = art.MAG1,
MAG2 = art.MAG2,
DES_DIS = art.DIS == 1 ? "Si" : "No"
};
但我不认为这是解决方案。我将把案例报告给NpgSQL。