C# :: Join Tables In LINQ With Lambda Expressions

Dec 5, 2014

i have stuck in a join and i cant figure out where the problem is, i have those tables

public class Themes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }

[Code].....

View 12 Replies


ADVERTISEMENT

C# :: Cannot Convert Lambda Expressions

Mar 31, 2015

I get the following error:

Cannot convert lambda expression to type system delegate because it's not a delegate type (on invoke).

The Second error is: Client.PrivateChat.txtReceive is inaccessible due to its protection level..

private PrivateChat pChat;
private void client_Received(Client sender, byte[] data) {
this.Invoke(() =>
{
for (int i = 0; i < clientList.Items.Count; i++) {
var client = clientList.Items[i].Tag as Client;
if (client == null || client.Ip != sender.Ip) continue;

[Code] .....

View 4 Replies View Related

C :: Join Two Strings?

Dec 14, 2014

How join two strings? basic reason is add given filename little text to end. I try do by hobby not school project program which converts files format x to format y.i dont say which formats becouse reading and writing is almost done. (only little amount code is needed).'

View 2 Replies View Related

C# :: How To Check If Record Exists In A Join

Apr 25, 2014

I have to check whether or not a record exists in a join and if not ignore that user but still load all the other information for that user

var db = Simple.Data.Database.OpenNamedConnection("sqlConn");
var expr1 = db.PON_APP_USERS.STATUS == 1;
var sUsers = db.PON_APP_USERS.FindAll(expr1)
.Select(
db.PON_APP_USERS.USERKEY,
db.PON_APP_USERS.LAST_NAME,
db.PON_APP_USERS.FIRST_NAME,

[Code] .....

View 8 Replies View Related

C# :: Using Linq To Get DriveInfo Of ONE Drive

Jul 23, 2014

I want some simple code which will return only the DriveInfo from one drive. I have the below code but it isn't displaying what I expect it to display, I have a feeling i'm using Linq wrong!

var dname = from n in System.IO.DriveInfo.GetDrives() where n.Name == "F" select n.VolumeLabel;
richTextBox2.AppendText(dname.ToString() + "
");

The above should return the devices VolumeLabel which is in port F.

Instead I get the following:

System.Linq.Enumerable+WhereSelectArrayIterator`2[System.IO.DriveInfo,System.String]

View 5 Replies View Related

C# :: Linq To SQL With Null Value In WHERE Clause

Apr 13, 2015

I am trying to query fields in a where clause using LINQ to SQL and for some reason I cannot figure out why it doesn't work:

var qryGetMonsterID = (from students in dbContext.tblStudentPersonals
where (students.givenname.Equals(fn)) && (students.familyname.Equals(ln)) && (students.middlename.Equals(mn)) && (students.email.Equals(e))
select students);

The returned SQL Syntax is:

SELECT [t0].[monsterid], [t0].[givenname], [t0].[middlename], [t0].[familyname], [t0].[homeaddress], [t0].[city], [t0].[state], [t0].[postal], [t0].[primaryphone], [t0].[secondaryphone], [t0].[email], [t0].[username], [t0].[lastmodified], [t0].[modifiedby]
FROM [dbo].[tblStudentPersonal] AS [t0]
WHERE ([t0].[givenname] = @p0) AND ([t0].[familyname] = @p1) AND ([t0].[middlename] = @p2) AND ([t0].[email] = @p3)

Not sure but the values for middle name could be null - because not everyone has a middle name and the same is true for e-mail.

View 6 Replies View Related

C :: How To Emulate Callback Mechanism - Pthreads Join

Jun 19, 2013

I am trying to emulate callback mechanism in C. The code I have is follows:

Code:
#include <stdio.h>
#include <pthread.h>

struct fopen_struct {
char *filename;
char *mode;
void *(*callback) (FILE *);

[Code] .....

If I do a pthread_join in fopen_t() it works perfectly fine. But if I do that in main() I get a segmentation fault error. I want to call it in main() because I want it to be non-blocking, is there any solution?

View 1 Replies View Related

C++ :: Put Two Arrays (chara And Shuffled) Into Third Array Join

Sep 23, 2014

I am puzzled with the strange behavior of my code below. The code has an apparent error but the results are correct. I am trying to put two arrays (chara and shuffled) into a third array join. The first 10 elements of 'join' should have the elements of 'chara' and the second half should have the elements of 'shuffled'.

You will note that in the second For loop, I am using 'chara' instead of 'shuffled' but when I print the contents of 'join' I am getting the correct numbers.

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,

On the other hand if I replace 'chara' with 'shuffled' in the second For loop, I am getting incorrect results.

1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,

Why is this happening? (I am using Codeblocks.)

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int chara[]={1,2,3,4,5,6,7,8,9,10};
int shuffled[]={11,12,13,14,15,16,17,18,19,20};

[Code] ....

The question is cross-posted at: [URL] ....

View 6 Replies View Related

C# :: Linq To XML - Populate List With Multiple Values?

Aug 26, 2014

I have an XML document, formatted as such:

<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Bookmark Name="1984" Folder="C:UsersmillerDownloads1984 (George Orwell) - Audio Book" Time="00:43:58.4080000" Chapter="0" />
</Books>

Each Element named Bookmark has 4 attributes, Name, Folder, Time, and Chapter.

I'd like to be able to just put all of them in ONE type of container, without making multiple lists... Is there any way, using Linq to XML, to maybe add all of these values to a Tuple?

View 14 Replies View Related

Visual C++ :: LINQ Query To Select Distinct Value From Datatable

Oct 29, 2013

I entered to Visual C++ 2010. Now my intention is to prepare a LINQ Query to select a distinct value from a datatable...

In C# My Query
============
var ProjLnkQry = (from P in MyClass1.ProjTbl.AsEnumerable() select P["proj_name"]).Distinct().ToList();

The above query I try to convert it into VIsual C++

auto DistDepQry=(from v1 in MyGlobalData::ProjectTbl::AsEnumaerable() select v1["depart_name"])->Distinct()->ToList();

But not succeeded.... I found the error like : "from" undeclared Identifier.....

View 2 Replies View Related

C :: Create Console Based Application That Can Join And Split Bitmap Image

Jun 27, 2013

i have to create a console based application in c language that can join and split bitmap images. the requirements of the application are as follows :

1. Split Image
Enter number of parts:
Enter source image path:
Enter destination folder:
2. Join Images (all images should be of same width and height)
Enter image path:
Join more Image (y/n):
3. Exit

Take care of following things:

- Application should show number of images processed while running.
- Acceptable Image format is BMP only.
- Application should give all the validations for correct image name, type, size, path, etc.

View 2 Replies View Related

C# :: Linq To SQL Query Not Directly Working But SQL Result Text Works

Apr 14, 2015

I am trying to query dates between two textbox values converted to datetime in C#. The dates are returning in the correct datetime and no conversion problem exists there.

However when I run the below LINQ to SQL query in C# it returns no enumerable results. But if I take the below code:

DbCommand dc = dbHistoryContext.GetCommand(qryRes);
Console.WriteLine(dc.CommandText);

and get the results as a string of text and cut and paste that into the SQL Server Management studio and execute it - then it works. What do I need to do to search between two dates so that it properly works. The field is of format Date in SQL Server if that matters and the fields being used to pass the information to it are DateTime. The compiler doesn't show any errors but it just doesn't return results.

var qryRes = (from res in dbHistoryContext.tblR
where res.updateddate >= dtDateFrom.Date && res.updateddate <= dtDateTo.Date
select res);

View 8 Replies View Related

C++ :: Using Lambda As Encapsulated Sub-function

Mar 6, 2014

I have this method called "walk" and what it's supposed to do is, walk through a bunch of triangles one step at a time (the're all connected [not to each other, but in a mesh]).

To do so, I need to perform a containment test.

Normally, I guess I'd just write a separate function but what if I wanted to be weird and write my inclusion test as a lambda in my walk method? Literally the only function that needs this code is my walk() procedure and I need to call the test an arbitrary amount of times.

Is this frowned upon? Would this be the jarring type of code I've been warned about? Or should I just say yolo and do what I want?

View 4 Replies View Related

C Sharp :: Linq - How To Group Values Week Wise And Store In Another Datatable

Apr 9, 2013

I have a datatable which comprises values from 1st January to march, something like this:

DataTable datatable = new DataTable("Employee");
datatable.Columns.Add("Date", typeof(string));
datatable.Columns.Add("Employee", typeof(string));
datatable.Columns.Add("Job1", typeof(double));
datatable.Columns.Add("Job2", typeof(double));  
datatable.Rows.Add(new Object[] { "1/4/2013", "A", 1.3, 2 });

[Code] ....

The result should look like this for Job1:

Employee 1/7-1/13 1/14-1/20 1/21-1/27 1/28-2/3 and so on...
A sum of values for this 7 days
B
C
D

I want to add all the values of Job1 for each employee in a time range which is one week starting from monday to sunday. How can I group the Job1 values week wise and store them in another datatable.

View 4 Replies View Related

C++ :: Expanding Variadic Template Arguments In Lambda

Feb 1, 2013

I'm trying to expand a template + argument parameter list inside a lambda function like this:

template <typename Class, typename ...Args>
static void create(Args ...args) {
// Perform pre-thread creation work.
std::thread([=]()

[Code] ....

But this does not work:

The compiler error is "error: parameter packs not expanded with ‘...’:|"

However, when I do the following:

template <typename Class, typename ...Args>
static void create(Args ...args) {
// Pre-thread work.
auto tthr = [](Args ...ar) -> void {

[Code] ....

It works just fine. That shows that lambda threads are able to take variadic arguments...

So here is my question; what is the correct capture clause for capturing the variadic object correctly?

View 3 Replies View Related

C++ :: Thread With Lambda Function - Swap 3 Variables

May 13, 2014

I am trying to realize a simple code with thread and lambda function.

My goal is to swap 2 variable . I launch 2 thread,

The first:
Put his value in a shared variable and notify it .
wait until an event on a condition variable occur.
read from shared value .

The second wait until an event on a condition variable occur.
Wake up
read from shared value .
Put his value in a shared variable and notify it.

This is the code

thread t1([&p1]()->void{
m.lock();
nt++;
if(nt==1) {
//first thread
unique_lock<mutex> u1(m); ***

[Code] .....

Why it say error "abort() has been called " on the istr ***

View 2 Replies View Related

C++ :: Generalized Sort Function Using Lambda Functions

Jan 15, 2014

How to improve my customSort function. It is to accept a lambda function as parameter which customizes your sort in any special way you want.

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <functional>

enum personType {teacher, student, baby};

[Code] ....

For example, std::vector<Person> people = {Mark, MrMac, Lola, MsWhite, Cindy, Zainab, Mikey, Fred, Zolal} is to be sorted so that teachers will be placed first, then students, and then babies, but with the exception that people with names starting with Z be placed before anyone else, followed by people with age equal to 8. All this is set up by the ordered list:

person.name.at(0) == 'Z',
person.age == 8,
person.type == teacher,
person.type == student,
person.type == baby

So the output gives

Zolal
Zainab (baby)
Cindy
Ms. White
Mr. Mac
Fred
Mark
Mikey (baby)
Lola (baby)

Teachers are supposed to be placed before students, which in turn placed before babies, but Cindy's age is 8, and so is placed before the teachers, and Zolal and Zainab start with Z, so is placed before her. So far so good, but now I want the further sorting result that all people within their subcategories be sorted in their own way, e.g. Zainab should come before Zolal alphabetically, Ms. White should precede Mr. Mac because she is younger, etc... How do I further generalize my customSort function so it carries out those further criteria as well?

View 9 Replies View Related

Visual C++ :: Constructor With Functional / Construction Via Lambda?

Feb 17, 2014

I have a class which upon construction has a part which should be executed when the constructor has finished "enough" to make the call valid.

Take the following simplified class example (the actual problem is much more elaborate):

Code:
#include <functional>
class base {
public:
base(int i, std::function<void()> func) : mi(i)

[code]....

Explicitely creating a derived class allows me to properly implement the lambda to call a member of the class.

I can't seem to figure out how to do this for an explicit instantiation of the base class.

Can this be done ? Or is this a shortcoming of VS2012 or something the standard doesn't handle ?

View 12 Replies View Related

C :: Cannot Use Array Name In Expressions

Nov 27, 2014

Code:

int main() {
char *arr[] = {"Hello", "World", "Good", "Morning"};
display(arr);
return;
}

[code]....

The code works fine and prints the 4 strings. Where i m riddled is whether "ptr" in display function is a pointer or a string ? If it's a pointer then what is the type of the pointer? If it's an array, then as per my understanding, we cannot use an array name in expressions such as ptr++ (K&R).

View 2 Replies View Related

C++ :: Passing Lambda As Template Parameter Not Working Correctly

May 30, 2013

I've was trying out a function template to automatically get the type of a lambda, but it seems that it won't compile

I've tried two different ways:

1.
template<class HASHER>
auto make_unordered_map(size_t bucketCount, HASHER const && hf)
-> unordered_map<string const, HASHER>&& {
return unordered_map<string const, int, HASHER>(bucketCount, hf);
} auto x = make_unordered_map(1, [](string const& key)->size_t { return key[0]; });

2.
template<class HASHER>
auto make_unordered_map(size_t bucketCount, HASHER const && hf2)
-> unordered_map<string const, int, decltype(hf2)> {
return unordered_map<string const, int, decltype(hf2)>(bucketCount, hf2);
} auto x = make_unordered_map(1, [](string const& key)->size_t { return key[0]; });

The test code are located here:

1. [URL] ....
2. [URL] ....

They are both based on the code that is stated to work in those examples. I.e.:

auto hf = [](string const& key)->size_t { return key[0]; };
unordered_map<string const, int, decltype(hf)> m (1, hf);

View 13 Replies View Related

C++ :: Regular Expressions Not Working?

Aug 25, 2014

I have this bit of code that I found here: [URL] and at first regex would work, but then when I hit "[]" it wouldn't. Here's the code:

#include <iostream>
#include <string>
#include <regex>

[Code]....

View 2 Replies View Related

C++ :: Lambda Accepts No Arguments But It Accesses Increment By Value And Current By Reference

May 24, 2013

In this code:

// Ex10_15.cpp Using lambda expressions
#include <algorithm>
#include <iostream>
#include <iomanip>

[code].....

The lambda accepts no arguments, but it accesses increment by value and current by reference, the latter being used to store the next value to be set. This lambda has the side effect that current will be updated when generate is finished. The following lambda expression is similar, but without the side effect:

[=]()mutable->T{T result(current);
current += increment;
return result;}
"

I dont exactly understand what side affect it is talking about. Wouldn't you want generate to update current? I understand how the second code fixes it though, just takes everything in the enclosing scope by value.

View 2 Replies View Related

C++ :: Use Boost / Regex For Regular Expressions?

Sep 5, 2013

So I need to use boost/regex for regular expressions. someone told me that it needs to be built. the first problem is boost doesn't tell you how to build it and the second is i did sudo apt-get install libboost something. I don't remember the exact name of the package. it installed but i dont know how i would build it when its installed.

View 2 Replies View Related

C++ :: Email Validation Without Using Regular Expressions?

Dec 11, 2013

writing a program for "Validating the e-mail id without using regular expressions in c/c++"?

View 4 Replies View Related

C++ :: Evaluating Logical Boolean Expressions

Jan 10, 2013

I am looking for a library to aid me in evaluating Boolean expressions. For example, i have an expression like this:

(1*(5+3)+9*65/5-(354*4565*5643+98) >= 12345) && ( 654*987+123 || (2345 > 23423 && 1 != 2)))

(It can also be much longer!) and would like to evaluate them to a true/false boolean.

There are tons of libraries to calculate the (numerical) result of a mathematical expression, but this is not what i want to do.

View 5 Replies View Related

Visual C++ :: Regular Expressions - How To Get Iterator

May 22, 2014

In order to parse mathematical expressions I am trying regular expressions and a recursive algorithm, but I have a problem with the four basic operations: +, -, *, /.

Trying to analyze a string like "a+(b+c)", if I use the pattern for a sum "(.+)+(.+)" the program matches it recognizing as subpatterns: "a+(b" and "c". How could I achieve the program to try also the other possibility?

I think that it would be great something like an regex_iterator which worked with regex_match instead of regex_search. I mean, an iterator that iterates over all the possible ways to match a given regular expression and a given string. This way I could loop through all these possibilities until the two subpatterns produced were correct mathematical expressions.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved