datacontext

How do I get the ColumnAttributes from a Linq.Table<TEntity>?

我是研究僧i 提交于 2020-01-25 00:06:22
问题 I'm trying to return attributes of columns from my DataContext. How can I pull out the ColumnAttribute meta data? public class MyDataContext : DataContext { public Table<User> User; public MyDataContext(string connection) : base(connection) { } } [Table(Name = "User")] public class User { [Column(IsPrimaryKey = true)] public long ID; [Column] public string FirstName; [Column(CanBeNull=false)] public string LastName; int VersionNumber = 1000; } How do I access the User object or Table<User>

“DataContext accessed after Dispose” error when disposing datacontext from ActionResult method in controller ASP.NET MVC 3

我的未来我决定 提交于 2020-01-17 07:08:06
问题 Here is my code: public ActionResult MainMenu(int id) { using (WebDataContext context = new WebDataContext()) { //var dataLoadOptions = new System.Data.Linq.DataLoadOptions(); //dataLoadOptions.LoadWith<MenuCache>(x => x.Menu); //context.LoadOptions = dataLoadOptions; var menu = context.MenuCaches .AsEnumerable() .Where(x => x.ID == id && (x.Local == true || x.National == true)); foreach (var item in menu) { if (item.Parent.Parent != null && item.Parent.ParentID == 0) { menu = item.Children;

How do I extract “eTag” or “x-ms-request-id” from my Astoria DataContext response?

一世执手 提交于 2020-01-16 11:09:25
问题 The Azure table whitepaper mentions that the x-ms-request-id is useful to send to Microsoft in the event there is an error working with the data. If I do have such an error, I'd like my try...catch block to take this and save it somewhere for future analysis. In addition I need to extract the ETag value as well while in Table storage. How do I extract this information and have it available when the Exception comes around? HTTP/1.1 204 No Content Content-Length: 0 ETag: W/"datetime'2008-10

Binding to SelectedItem with a referenced ItemsSource

坚强是说给别人听的谎言 提交于 2020-01-14 19:29:06
问题 Intro I have got a pool of different DataSources. I've got Masks. Masks have got Indexlines. Each Indexline has a single DataSource from the pool associated: Classes public class DataSource { public string Name { get; set; } public override string ToString() { return Name; } } public class Mask { public string Name { get; set; } public ObservableCollection<Indexline> Indexlines { get; set; } public override string ToString() { return Name; } } public class Indexline { public DataSource

DataTemplate for ListBox element is not binding at all

ε祈祈猫儿з 提交于 2020-01-05 07:31:15
问题 I have a ListBox element, which purpose is to show the users the activities, that are registered on the Database so that they can choose from them to modify or delete them. After consulting two very useful answers about using DataContext and DataTemplates, I decided to implement that knowledge in my project, unfortunately, it's not working. When I run it and I select the text on the ListBox , I only see: DataTemplate templ = new DataTemplate(typeof(Activities)); as its content, and I didn't

linq to sql datacontext for a web application

别等时光非礼了梦想. 提交于 2020-01-05 07:00:11
问题 I'm trying to use linq to sql for my project (very short deadline), and I'm kind of in a bind. I don't know the best way to have a data context handy per request thread. I want something like a singleton class from which all my repository classes can access the current data context. However, singleton class is static and is not thread-safe and therefore not suitable for web apps. I want something that would create a data context at the beginning of the request and dispose of it along with the

Binding to BitmapImage

孤人 提交于 2020-01-05 03:56:06
问题 public class Thumbnail : INotifyPropertyChanged { public BitmapImage testimage { get; set; } Thumbnail() { testimage = new BitmapImage(new Uri("http://www.diseno-art.com/news_content/wp-content/uploads/2012/09/2013-Jaguar-F-Type-1.jpg")); } } And a image element in a custom control: <Image x:Name="previewImage" x:FieldModifier="public" Margin="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Source="{Binding Path=thumbnail.testimage}" Stretch="Fill" /> When i create a control, i

Multi-level databinding on UserControl menu dependant on each other

牧云@^-^@ 提交于 2020-01-03 07:09:25
问题 I have a property Tours : Tours is an ObservableCollection of class Tour Each "Tour" has an ObservableCollection Parties of class Partie Each Partie has an ObservableCollection Equipes of class Equipe I have 3 menus : The first is is bond with the property Tours The second must be bond with the SelectedItem property of the first menu (so it has an ObservableCollection of class Partie ) The third must be bond with the SelectedItem property of the second menu. (so it has an ObservableCollection

How to move the DataContext definition from code-behind to XAML?

时光毁灭记忆、已成空白 提交于 2020-01-03 02:57:33
问题 I defined an object which contains properties in code-behind and, want to set the object to datacontext in xaml. namespace WpfApplication4 { public partial class MainWindow : Window { public EquipInfo equip1; public MainWindow() { InitializeComponent(); equip1 = new EquipInfo(); // setting here works fine but i want to do in xaml //textBox1.DataContext = equip1; } } } here's xaml code.. <Window x:Class="WpfApplication4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml

Inheriting LINQ-to-SQL data context from base controller

瘦欲@ 提交于 2020-01-02 05:04:31
问题 My base controller class, BaseController , is inherited by public-facing controllers to access a shared data context between requests with LINQ-to-SQL. Am I accessing my data context in an efficient and safe way by storing it in HttpContext.Current.Items for each HTTP request? DataContextHelper class internal static class DataContextHelper { public static MyDataContext CurrentContext { get { if (HttpContext.Current.Items["MyDataContext"] == null) { MyDataContext context = new MyDataContext();