时间:2019-03-17 标签:c#silverlightwcfmysql
我有 silverlight 4 应用程序。托管 ASP.NET Web 应用程序。启用 WCF RIA 服务。从服务器端 apache2 php5 Mysql。使用 MySql 连接器、ADO.NET 实体数据模型、域服务类,我可以访问 MySql 数据库。工作得很好...(对我来说慢慢地,但是工作)。
表:
languages
LANG_ID char(10)
LANG_NAME char(40)
LANG_NAME_SHORT char(10)
LANG_IMAGE blob
LANG_PATH char(100)
DEFAULT char(1)
STATUS_ID char(1)
xaml:
<ComboBox x:Name="Language_Choice" Height="25" Width="110">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding LANG_PATH}" Width="16" Height="16"></Image>
<TextBlock Text="{Binding LANG_NAME_SHORT}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
代码:
DataDomainContext _context = new DataDomainContext();
EntityQuery<languages> _query = from _l in _context.GetLanguagesQuery()
where _l.STATUS_ID == "Y"
orderby _l.LANG_NAME_SHORT
select _l;
LoadOperation<languages> _loadOp = _context.Load(_query);
Language_Choice.ItemsSource = _loadOp.Entities;
问题: 我希望将结果查询放入列表:
public class LangChoice
{
public string LangID { get; set; }
public string LangName { get; set; }
public byte LangImg { get; set; }
public string LangPath { get; set; }
public string LangDef { get; set; }
} List<LangChoice> LangList = new List<LangChoice>();
有什么方法可以将结果放入列表并保存列表项索引,其中 languages.DEFAULT ==“Y”。 没有列表我不知道 xaml 或代码中定义的 Language_Choice.SelectedIndex=0;(error=out of range) 。
我是新的“开发人员”。 我是否编写了通用代码 SELECT,例如:“SELECT fild1, fild2 FROM table WHERE field_900="HELP" ...” 我不会从表中生成所有字段,仅定义。 环境(c# Silverlight、Apach、PHP、MySql 和 WCF RIA 服务)
转发感谢
I have silverlight 4 app. host ASP.NET web app. enabled WCF RIA services. From sever side apach2 php5 Mysql. With MySql connector, ADO.NET Entity Data Model, Domain Service class I have access to MySql database. Work fine... (for me slowly, but WORK).
table:
languages
LANG_ID char(10)
LANG_NAME char(40)
LANG_NAME_SHORT char(10)
LANG_IMAGE blob
LANG_PATH char(100)
DEFAULT char(1)
STATUS_ID char(1)
xaml:
<ComboBox x:Name="Language_Choice" Height="25" Width="110">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding LANG_PATH}" Width="16" Height="16"></Image>
<TextBlock Text="{Binding LANG_NAME_SHORT}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Code:
DataDomainContext _context = new DataDomainContext();
EntityQuery<languages> _query = from _l in _context.GetLanguagesQuery()
where _l.STATUS_ID == "Y"
orderby _l.LANG_NAME_SHORT
select _l;
LoadOperation<languages> _loadOp = _context.Load(_query);
Language_Choice.ItemsSource = _loadOp.Entities;
Question:
I want result query put into List:
public class LangChoice
{
public string LangID { get; set; }
public string LangName { get; set; }
public byte LangImg { get; set; }
public string LangPath { get; set; }
public string LangDef { get; set; }
} List<LangChoice> LangList = new List<LangChoice>();
Is there any way to put result to list and save list item index where languages.DEFAULT == "Y".
Without list I don't know defined Language_Choice.SelectedIndex=0;(error=out of range) in xaml or code.
I'm new "developer". Is I write a code generic SELECT like: "SELECT fild1, fild2 FROM table WHERE field_900="HELP" ..." I don't wont result all field from table, only defined.
Environment (c# Silverlight, Apach, PHP, MySql with WCF RIA Services)
Forwards Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到一种方法“答案”...
添加到 ASP.NET Web 应用程序项目:新的“启用 Silverlight 的 WCF 服务”。写入以下代码:
在 web.config 中创建连接:
; <添加名称=“MyConnection”providerName=“MySql.Data.MySqlClient”
connectionString="server=localhost;用户 ID=root;密码=***;数据库=****;持久安全信息=True"/>
在 Silverlight 客户端项目中:添加“服务引用”。
现在代码如下:
更改 XAML:
I find one way "answer"...
Add to ASP.NET Web Application Project: new "Silverlight-enabled WCF Service". Write to following code:
In web.config create conecction:
<connectionStrings> <add name="MyConnection" providerName="MySql.Data.MySqlClient"
connectionString="server=localhost;User Id=root;password=***;database=****;Persist Security Info=True"/>
</connectionStrings>
In Silverlight client project: Add "Service Reference".
Now Code some think like:
Change XAML: