我的SQL服务器数据库中有一个地址数据表.此表未规范化,因此它包含许多重复的地址.可以通过Id字段识别每个唯一地址(这些ID经常在表中重复).
所以我在表上创建了一个视图,使用原始表中的Select Distinct(AddressId)提取所有唯一的地址.
现在我想在这个视图上创建一个索引以提高搜索速度,但是SQL服务器不允许我在视图上创建一个索引,因为它包含一个不同的或分组的(我已经试过看看它是否会允许我创建索引)
有人有解决方案吗?或任何其他方式来执行此操作.
我需要根据地址关键字查询此视图,并根据匹配计数返回一个,我有这个查询,我试图通过索引视图中的字段来加快它.
SQL Server 2008
SELECT
AddressId,
AddressNumber,
AddressName,
Town,
City,
Country,
COUNT_BIG(*) As AddCount--,
--TRIM(AddressNumber + ' ') + LTRIM(AddressName + ' ') + LTRIM(Town + ' ') + RTRIM(City + ' ') AS AddressLookup
FROM
[Address] A
GROUP BY
AddressId,
AddressNumber,
AddressName,
Town,
City,
Country
Run Code Online (Sandbox Code Playgroud)
是我的查询....
如果我用AddressLookup取出列,我可以添加索引
干杯
我有一个视图模型,它继承自一个有一个名为IsReadOnly的属性的基类.在这个视图模型中,我有一个名为Customer的属性,我将客户对象的属性绑定到我的视图上的控件.
但是我也希望能够将IsReadOnly绑定到我视图上的每个控件.
<TextBox x:Name="FirstNameTextBox" Grid.Column="1" Margin="2,2,0,2" Grid.Row="2" TextWrapping="Wrap" HorizontalAlignment="Left" Width="200"
Text="{Binding FirstName, Mode=TwoWay}" IsReadOnly="{Binding MyViewModel.IsReadOnly}"/>
Run Code Online (Sandbox Code Playgroud)
我怎样才能使用这两个属性?这是我的结构
公共类MyViewModelBase {public bool IsReadonly {get; set;}}
公共类MyViewModel {public Customer Customer {get; 组; }}
public class Customer {public string FamilyName {get; 组; }}
欢呼任何帮助
在执行存储过程时,是否可以从LINQ To SQL DataContext返回输出参数?
IEnumerable<Address> result =
ExecuteQuery<Address>(((MethodInfo)(MethodInfo.GetCurrentMethod())),
address, pageIndex, pageSize, totalCount);
Run Code Online (Sandbox Code Playgroud)
其中address,pageIndex与pageSize被输入的参数,并且TotalCount是一个输出参数.
如何捕获输出参数?
这是另一种尝试,但再次无法获取参数值:
[Function(Name = "Telecom.AddressSearch")]
private IEnumerable SearchAddress([Parameter(Name = "address", DbType = "varchar")] string address,
[Parameter(Name = "pageIndex", DbType = "int")] int pageIndex,
[Parameter(Name = "pageSize", DbType = "int")] int pageSize,
[Parameter(Name = "totalCount", DbType = "int")] ref int totalCount)
{
IEnumerable result = ExecuteQuery(((MethodInfo)(MethodInfo.GetCurrentMethod())), address, pageIndex, pageSize, totalCount);
return result;
}Run Code Online (Sandbox Code Playgroud)