I have a D object created from the automatic mapping of the D table. I added the following property to it in a partial class.
public Address PhysicalAddress
{
get { return this.Addresses.FirstOrDefault(a => a.AddrType == "PHY"); }
}
This works fine on it's own.
I'd like to write the following linq query on it:
var result = from ...
Hi folks,
how can the ThenBy be translated to Linq-To-Sql, please?
var movies = _db.Movies.Orderby(c => c.Category).ThenBy(n => n.Name)
var movies = from m in _db.Movies
orderby m.Category
// What's the syntax for ThenBy?!
// thenby m.Name
select m;
When i try to do thenby m.Name...
I am new in the functional side of C#, sorry if the question is lame.
Given the following WRONG code:
var jobSummaries = from job in jobs
where ...
select new
{
ID = job.ID,
Description = job.Description,
Fi...
I need a function, which is capable of iterating over the collection, calling a supplied function with element of the collection as a parameter and returning the parameter or it's index when received "True" from supplied function.
It is somethong like this:
def find(f, seq, index_only=True, item_only=False):
"""Return first item i...
I am trying to create Linq Expression that I can use to query child entity for parent properties(PATIENT entity in this case), using this method:
private IQueryable<LAB_ORDER> SelectFilter(string fieldName, string value)
{
var param = Expression.Parameter(typeof(PATIENT), "item");
var field = Expression.PropertyOrField(param, fiel...
I need to build an expression that will work on a parent entity properties so will do the following:
IQueryable<Children> allChildren = from e in context.Children select e;
IQueryable<Children> filter = allChildren.Where(x => x.Parent.Name == "Value");
I created an expression of type Expression.Lambda<Func<Parent, bool>> for that bu...
I have an Expression<Func<T,DateTime>> I want to take the DateTime part of the expression and pull the Month off of it. So I would be turning it into a Expression<Func<T,int>> I'm not really sure how to do this. I looked at the ExpressionTree Visitor but I can't get it to work like I need. Here is an example of the DateTime Expression
...
My code has something like this:
HttpFileCollection files
Instead of looping through each file and adding up the file.ContentLength to get the total length of all content e.g.
int totalLength = 0;
for (int i = 0; i < files.Count; i++)
{
totalLength += files[i].ContentLength;
}
Is there a ...
Reading the documentation it seems this might not be possible, but it seems that a lot of people have been able to beat more complicated functionality into pythons lambda function.
I'm leveraging the scapy libraries to do some packet creation. Specially this questions is about the ConditionalField which takes it a field and a compariso...
Hello,
would someone please write this code:
this.Loaded += (s, e) => this.loaded = true;
into several code lines so I can retrace the meaning?
In my code sample there is no s or e ?
...
Hi,
I wrote a custom ordering LINQ extension method as below but I think it can be optimized for large results.
Here is the code :
public static IEnumerable<T> OrderByAncesty<T>(this IEnumerable<T> source, Func<T, DateTime> dateSelector, Func<T, float> scoreSelector)
{
var original = source.ToList();
var maxDat...
I have no idea if this is possible ... but it would be cool. the question is whether it is possible but then a bit of an example if possible.
I am not sure what method signature you would use to pass the lambda expression into.
Eg the method IList<Group> GetGroups()
How would you modify that to be able to pass a lambda expression into...
I have an xml document which consists of a number of the following:
- <LabelFieldBO>
<Height>23</Height>
<Width>100</Width>
<Top>32</Top>
<Left>128</Left>
<FieldName>field4</FieldName>
<Text>aoi_name</Text>
<DataColumn>aoi_name</DataColumn>
<FontFamily>Arial</FontFamily>
<FontStyle>Regular</FontStyle>
<Fon...
Hi,
is there way how to get name ov event from Lambda expression like with property (
http://stackoverflow.com/questions/671968/retrieving-property-name-from-lambda-expression ) ?
Thanks
...
I am using the following code to pass a property to a lambda expression.
namespace FuncTest
{
class Test
{
public string Name { get; set; }
}
class Program
{
static void Main(string[] args)
{
Test t = new Test();
t.Name = "My Test";
PrintPropValue(t => t.Na...
I've just started using AutoMapper and so far found it very straight-forward and time-saving.
Just one thing I'm not sure about - how do I map all the properties of a given type in the same way?
Can this be done with AutoMapper in a single statement, using a lambda, as with regular mapping?
...
I'm trying to implement method Find that searches the database.
I forgot to mention that I'm using Postgresql, so I can't use built in LINQ to SQL.
I want it to be like that:
var user = User.Find(a => a.LastName == "Brown");
Like it's done in List class. But when I go to List's source code (thanks, Reflector), I see this:
public T ...
Update2:
What I really wanted to ask was already argued in a different page. Please check the following entry. (Thanks to BobS.)
http://stackoverflow.com/questions/598878/how-can-i-access-local-scope-dynamically-in-javascript
Hello.
I've started using jQuery and am wondering how to call functions in an anonymous function dynamically ...
Please interpret this code :
public static Func<TInput1, TOutput> Curry<TInput1, TOutput>(this Func<TInput1, TOutput> f)
{
return x => f(x);
}
OR
Func<Int32, Int32> SubtractOne = x => x - 1;
what is the name of these techniques?
...
I have some logic in a method that operates on a specified type and I'd like to create a generic lambda that encapsulates the logic. This is the spirit of what I'm trying to do:
public void DoSomething()
{
// ...
Func<T> GetTypeName = () => T.GetType().Name;
GetTypeName<string>();
GetTypeName<DateTime>();
GetTypeNa...