« first day (1586 days earlier)      last day (2563 days later) » 

2:07 PM
'morning all
 
Morning, Lynn
Got a LINQ/EF question...
 
:)
 
Fire away
 
How do I return this as an "awaitable"?
public async IEnumerable<string> GetUserIdsAsync()
{
	using (var db = new MyEntities())
	{
		var query = db.Users
			.Select(x => x.Login_ID)
			.OrderBy(x => x);

	}
}
Is it possible with IEnumerable or should I return a list?
 
2:11 PM
I know very little about this stuff...
can't you just return await db.Users.Select(x => x.Login_ID).OrderBy(x => x);
 
Got it!
 
Or does it always need to return Task<T> ?
 
That was it: return await db.Users.Select(x => x.Login_ID).OrderBy(x => x).ToListAsync();
 
Ahh- ToListAsync()
 
I was trying to follow good practices and use IEnumerable as the return type
 
2:14 PM
That returns Task<List<object>>
 
Yep
 
So it does need to return a Task<T>
Makes sense.
 
The return type must be a Task<T>
 
very nice.
 
@Alex this signature feels wrong
 
2:19 PM
Is anyone familiar with this? thematic.codeplex.com
 
async without Task is bad idea (for return type)
 
Nope... I had it incorrectly. It's always with Task<T>
 
ok do you know why you're doing ToListAsync()? cos it feels like cargo culting code :)
 
I used to do the really bad, evil deed of writing public async void
 
@Hypersapien not me and sounds unlikely that most of residents here would have seen that
 
2:20 PM
@Hypersapien Never used it
 
the last update is older than the age of this channel.. i wouldn't recommend looking into it
 
@Maverik I've been writing a lot of async calls for an app. At this stage, small number of users. But the external facing one will have a lot
Need advice on how to do best practices in this :)
 
tad too formal for comfort! :P
 
Edited ;)
 
if you want to do async heavy ef - you should be focusing on efcore
 
2:23 PM
Sorry, been writing emails and stuff
Tend to be formal in those
 
yea but i have a explicit switch on mode for that
with my boss.. its more like "done" <-- net content of my email.. then signature block
 
Ahh, you're luck
 
no hi.. no dear.. no kind regards and such :)
well i've conditioned him into it - when the conversation is just between the two of us, i do away with formalities
 
One of my professors always wanted me to call him by his first name. Could never get used to it
Always called him "Dr. ..."
 
I can imagine Mr. Xxx, Alex
 
2:25 PM
Hehehe
If I were using EFCore, how would that db call differ?
 
ok so async ef..
its got builting async support .. rather than an afterthought like in EF6
 
Sounds good so far
 
i'm looking up the async stuff.. please hold :)
plays music
hmm seems they're using the same extension methods
makes sense i guess.. easier porting over
 
Yeah, that makes it easy
public async Task<List<Blog>> GetBlogsAsync()
{
    using (var context = new BloggingContext())
    {
        return await context.Blogs.ToListAsync();
    }
}
Keeping the extension methods the same will help us devs not have to rewrite tons of code
 
yea they've retained as much of the old api methods as they could when porting over to efcore
 
2:36 PM
Nice
 
(efcore can still target .net framework full so no reason not to use it if it already serves your general case)
it's also a lot faster - and you can use it side-by-side for gradual migration
 
Is there an article out there explaining all the "Core" stuff? I'm kinda lost... ASP.NET Core, .NET Core, EF Core. I think these are the next versions of the tech, but not entirely sure
 
yea they are
 
No need to look em up now :)
 
they originally started life targeting only .net core
but now that they're targeting .netstandard 1.x stuff - you can use it on full .net as well
asp.net core is still targetting .net core only i think
but ef core supports .net 4.5.1+
 
2:43 PM
In the old days, MS had live webinars where you could ask questions. They had them daily... back 10+ years ago
We could ask them questions about this stuff
 
If I download and install a theme, but I have my own theme file with specific key-based themes, how can I have them both apply to a control if they aren't in conflict with each other?
 
3:04 PM
BasedOn
 
3:17 PM
    <Grid>

        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <WrapPanel Grid.Column="0" Orientation="Horizontal" Background="Blue" />

        <WrapPanel Grid.Column="1" Orientation="Horizontal" Background="Green">
            <Border Width="100" Height="30" Background="Red" />
            <Border Width="100" Height="30" Background="Red" />
is there a way i can structure this so that the wrappanel with items in it gets more space?
hypothetically any of the wrappanels could have 0 or more items
looks like no one is around today wtf
 
You'll have to commute column definition with wraps that doesn't have items to Width="Auto"
 
@Julien You mean whichever one has items in it, not necessarily the second one like in your example?
 
i guess the perfect scenario would be that columns with no items consume a minimum width, while columns with items share width
that width being as much as is possible
i think @NovitchiS solution is good
hm. not really
i guess what i am asking for is pretty tricky
a column with 1 item should consume less then a column with 20
if i set all the columns to auto, i get the behavior i want, but nothing ever wraps, because nothing is constraining the column width
it even pushes content off screen, which seems weird
 
3:33 PM
sounds like it'd need a custom bind to wrappanel.children.length to be used as width ratio (3*)
 
If you give a x:Key to a Style, you have to refer to that style by the key in a control in order for it to be applied to that control, right?
 
@Hypersapien yes
@Maverik can you expand a bit? not sure how or where i would use the number of items
 
Ok, so how can I use BasedOn to reference a global style, that doesn't have to be referred to by its key?
 
your x:key defined style can be BasedOn some other style
<Style x:Key="MyCustomStyle" BasedOn="{StaticResource SomeThirdPartyStyle}" >
if there is a global style that you aren't referencing by key, any custom style will override that
you have to BasedOn by name
this applies for example when you use MaterialDesign theme
 
Give the global style a x:Name instead of an x:Key?
 
3:42 PM
anything resource based should be using key, shouldnt it?
i always get key and name mixed up
 
By default, that global style didn't have a name or a key. I want to keep it as a global style and not have to reference it by name in my controls.
But I have another style in a different ResourceDictionary that I want to have a key, but have it be based on the global style.
Right now, if a control uses the key, it gets the keyed style but NOT the default one.
 
not sure you can
good question
 
Fuck it. I'll make a copy of the default one. It's five lines long and is getting everything from a separate ControlTemplate anyway.
 
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0*" MinWidth="100" />
            <ColumnDefinition Width="1*" MinWidth="100" />
            <ColumnDefinition Width="0*" MinWidth="100" />
            <ColumnDefinition Width="0*" MinWidth="100" />
        </Grid.ColumnDefinitions>
that gives me good behavior. so i think if i could find a way to toggle the 0* to some number based on the number of items, it might work?
bleh. math. ><
 
I recently had to set up a system where I needed to dynamically change the width of Grid Column/Row Definitions
 
3:56 PM
@Julien sorry just saw this: you know how you can give relative widths to grid?
 
Are the contents of the grid going to stay the same for the lifetime of the control?
 
no stuff can get added and removed
 
1* 2* kinda where second column will take twice the space of first -- if they could take in widths from this children then ratio would get adjusted as you want it
i believe Width isn't a DP though, so custom stuff is in order -- Johan's grid implementation would be a good start for that
 
to do that, every column would have to know how many items are in every other column, right?
 
no just their own
grid will do the relative width ratio on its own
 
3:59 PM
"my column has the most items, set width to 2*"
 
nope
ColumnDefintion Width="{Binding Children.Length}*
^ that won't work of course, but to illustrate the idea
 
yeah, i get the idea
not sure how to translate it to a grid length
 
you'd probably want to use some logarithmic scaling on top of this to avoid getting this out of hand
well Johan's autogrid deals with widths internally.. so that could be a place to start
if Width was a DP, you could use binding as well a converter and this would be dandy
hmm I wonder.. <ColumnDefinition><ColumnDefinition.Width><GridLength Value="Children.Length" IsStar="True" />...
the children.length still needs a way to hook into this stuff
can't think of any easy way of doing this other than a subclass
hmm Value is readonly anyway, so GridLength can't be created directly..
 
yeah just tried
 
subclass seems to be only direction.. you'd need to influence layout pass each time any of the children collection changes
given the niche nature of this, subclassing makes sense
 
4:13 PM
welp i think i got somethign that works
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var itemCount = (int) value;
            return new GridLength(itemCount, GridUnitType.Star);
        }
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{Binding Path=Children.Count, ElementName=FirstWrapPanel, Converter={StaticResource WrapPanelConverter}}" MinWidth="100" />
            <ColumnDefinition Width="{Binding Path=Children.Count, ElementName=SecondWrapPanel, Converter={StaticResource WrapPanelConverter}}" MinWidth="100" />
            <ColumnDefinition Width="{Binding Path=Children.Count, ElementName=ThirdWrapPanel, Converter={StaticResource WrapPanelConverter}}" MinWidth="100" />
lol. pure luck
 
4:34 PM
Hi All, So i have installed NUnit and happily writing unit tests left, right and center. Its good once you get your head around it. My next task is creating a search tool to search several fields and tables in SQL Server. I am primarily looking to learn new skills, any suggestions on what I should look at for this? It would have to be free :)
 
Are you using EF, or hitting it directly?
 
hitting it directly to start with
but I am open to all suggestions as I am learning :)
 
query the schema, get a list of tables, iterate through tables, query schema for columns, query columns
 
Start with a textbox that's bound to a string in the vm.... and a button bound to a command.... make the command execute a search... bring back the results and transform them into an ObservableCollection<class>... bind that OC to an ItemControl (ItemsSource={Binding YourCollection})
That's your master-view
Then set up double click, or a link, or something that opens up a detail view for that row.
 
would you use something like Linq to do that or create a view directly in the db?
 
4:42 PM
(Your textbox will be the search criteria)
I'd just execute a query via ADO.Net, unless you're using EF
 
great thank you :)
 
^ scroll to the bottom of that page, and look at the example
Your connection string will probably be different
 
@TheresaFerguson You probably want something like this: connectionstrings.com/sql-server
@TheresaFerguson One more note - I tend to use SqlDataAdapter to fill a DataTable
(scroll for example)
 
Highly recommend learning EF, Theresa
 
4:56 PM
Yes - EF will take much of the low-level stuff out of the equation
@Alex Are you EF Core, or EF6?
(And do you have a recommendation for her using one vs. the other?)
Theresa - EF Core is effective EF7... but they completely rewrote it... so they couldn't really call it that.
EF Core is still not as feature-complete as EF6 is... but still very usable
And EF6 is heavily bloated. And slow for certain operations.
 
5:22 PM
@Julien nice.. i didn't think Width would let you bind.. but awesome
EF Core has enough features right now to deal with "mainstream" operations though
 
5:37 PM
ef is gross. bleh.
 
for those times one can always just write sql
 
6:17 PM
I have a stylesheet for a TabControl with a ScrollViewer around the ContentPresenter. No matter what I do to it, I can't get the control in the TabItem to be Left aligned AND have ScrollViewer expand to the size of the content area. I can get one or the other, but not both.
 
show some xaml and i'll try it
 
@LynnCrumbling EF6
 
that is soooo much code
isnt there a simple example
 
6:33 PM
The contentpresenter is on line 45
That scrollviewer is the entire contentarea
How do you edit text on that site?
 
<TabControl>

  <TabControl.Template>
    <ControlTemplate>
      <ScrollViewer>
        <ContentPresenter />
      </ScrollViewer>
    </ControlTemplate>
  </TabControl.Template>

</TabControl>
yes?
this is what i mean by simple example :)
 
Well, there's a seperate ResourceDictionary file that holds the style.
 
right, but isn't it easier seeing it without that level of abstraction?
it also lets you test
 
Yeah
Is there a way I can see the internal structure of the built in WPF controls like TabControl? Is that documented anywhere?
 
this was actually brought up last week by the guy asking for blend
 
6:39 PM
shuold be on its MSDN page
 
supposedly you can pull the default template xaml out of VS but i dont know how
 
right click the control ;)
its probably one of the very few things the VS XAML Designer is good for
 
"Edit Style" nice
 
 
3 hours later…
9:51 PM
If I set up an animation style, how do I have it be always running? Every example I can find uses some kind of mouse event to start it.
 
Should just be able to set the animation in the style. What's the animation?
 
Loading bar
Defining the animation isn't a problem I have that figured out.
Where does the storyboard actually go, though?
 
Can you show me the code for it?
If it's set in the style, and you want it done nonstop, then it should just go nonstop from the time it renders.
I believe the storyboard has a target property you can set. And as long as you set the duration and repeat settings correctly, it should go on until the control is disposed of.
 
Right now it's in Style.Triggers because I don't know where it's supposed to go. Setter won't let me put in StoryBoard for a Property. Only some property OF StoryBoard.
 
Did you try putting the storyboard in the control's resources and set the storyboard's target to that control?
 
10:01 PM
It's already in the resources
 
outside the trigger?
 
No, inside the trigger. I can't figure out what the proper syntax is to put it outside.
 
Hmm. Well, is there a loaded event or something similar that could start it?
Yeah, looks like it has to be from an event.
 
I thought I had something, but it didn't work. gist.github.com/anonymous/d3e91806639e61c3fdaab46370046ab1
 
Do you want it to go back and forth or just one way then start over?
 
10:14 PM
one way and start ove
I'm going to fix it so the end matches up with the beginning
 
Instead of in the style, put it in the triggers again. Something like:
<Border>
  <Border.Triggers>
    <EventTrigger RoutedEvent="Border.Loaded">
      <!-- Do your animation -->
    </EventTrigger>
  </Border.Triggers>
</Border>
But then you can't set your background, I don't think. Otherwise it will overwrite the animation.
 
Does not point to a DependancyObject
 
GradientStop.Offset isn't a DO.
 
I think it's talking about Border. I'm not sure, though
Full error is
An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll

Additional information: '[Unknown]' property does not point to a DependencyObject in path 'BorderBrush.(0)[1].(1)'.
 
BorderBrush.(GradientBrush.GradientStops)[1].(GradientStop.Offset) is BorderBrush.(0)[1].(1)
 
10:27 PM
Yeah, I just realized that
 
So it looks like it might be a little more complicated :-/
 
10:42 PM
Hi all, I'm trying to do something a bit complicated, and I don't know the syntax for it, or if it's even possible. I'm hoping someone here can help me out.
What I'm trying to do is pass a class as a parameter. That is App.PushToPage(Page newPage, Page fromPage, Class addNewPageToExistingNavStackIfItContainsAPageOfThisClass);
Something similar to that
I'm okay passing a string instead of a class, but I'm not aware of a way to find a Page's (or any object's) class (Intellisense doesn't give me any indication that that's even possible)
There's a ClassId, but I can't even find any documentation for what that means, is, or represents
 
11:03 PM
I found object.GetType(), which looks like I might be able to use it for what I'm going for, but there's no static GetType() method on objects, so I have to instantiate an object to get its Type. This seems really wasteful; is there an efficient way of getting a Class's Type so I can send it along as a parameter?
 
typeof(NameOfTheType)
 
11:26 PM
Oh! Okay, thanks! I'll give that a shot.
 

« first day (1586 days earlier)      last day (2563 days later) »