Giter Site home page Giter Site logo

Comments (7)

jotab123 avatar jotab123 commented on May 17, 2024

I don't know if it's possible to do in Select but you could do:

var test1 = _context.Blogs.AsQueryable().Where("ModifyDate != null")
.Select("ModifyDate.Value.ToString(\"yyyy-MM-dd\")");

from system.linq.dynamic.core.

winsonet avatar winsonet commented on May 17, 2024

jotab123, thanks for your reply, but this is not my purpose, in your way, just find the not null value, but actually, I need to find all values, if it's null then will show empty or other thing, otherwise will format it and display

from system.linq.dynamic.core.

StefH avatar StefH commented on May 17, 2024

Why not just execute the ToString method on a list instead of the queryable ? In that case you don't have issues with Linq-SQL.

from system.linq.dynamic.core.

winsonet avatar winsonet commented on May 17, 2024

sorry, can you give me a sample how to do that? thanks!

from system.linq.dynamic.core.

StefH avatar StefH commented on May 17, 2024
var list = _context.Blogs.Select("it.ModifyDate").ToDynamicList<DateTime>();
var result = list.Select(x => x ?? x.Value)).ToString("yyyy-MM-dd")).ToList();

from system.linq.dynamic.core.

winsonet avatar winsonet commented on May 17, 2024

but for my case, I need to generate a full dynamic query for get the result, and I don't want to convert to list at first, because I have a lot of data in the table, if it to list first then will get all data and the performance will be bad, that why I need to use IQueryable .

and I know if I convert to list object then I can easy to use HasValue method in the query.

from system.linq.dynamic.core.

StefH avatar StefH commented on May 17, 2024

Did you already try the ? operator ?

Like

var q = _context.Blogs.AsQueryable();
var x = q.Select("it.ModifyDate != null ? [[[format to string]]] : null");

from system.linq.dynamic.core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.